@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * |
376 | 376 | * @access public |
377 | 377 | * @param \EE_Question_Option $QSO EE_Question_Option |
378 | - * @return boolean |
|
378 | + * @return boolean|null |
|
379 | 379 | */ |
380 | 380 | public function add_temp_option(EE_Question_Option $QSO) |
381 | 381 | { |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | * |
389 | 389 | * @access public |
390 | 390 | * @param string $property |
391 | - * @param mixed $value |
|
392 | - * @return mixed |
|
391 | + * @param boolean $value |
|
392 | + * @return boolean|null |
|
393 | 393 | */ |
394 | 394 | public function set($property = null, $value = null) |
395 | 395 | { |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * get_meta |
438 | 438 | * |
439 | 439 | * @access public |
440 | - * @param mixed $key |
|
440 | + * @param string $key |
|
441 | 441 | * @return mixed |
442 | 442 | */ |
443 | 443 | public function get_meta($key = false) |
@@ -13,435 +13,435 @@ |
||
13 | 13 | class EE_Question_Form_Input |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * EE_Question object |
|
18 | - * |
|
19 | - * @access private |
|
20 | - * @var object |
|
21 | - */ |
|
22 | - private $_QST = null; |
|
23 | - |
|
24 | - /** |
|
25 | - * EE_Answer object |
|
26 | - * |
|
27 | - * @access private |
|
28 | - * @var object |
|
29 | - */ |
|
30 | - private $_ANS = null; |
|
31 | - |
|
32 | - /** |
|
33 | - * $_QST_meta |
|
34 | - * @access private |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - private $_QST_meta = array(); |
|
38 | - |
|
39 | - /** |
|
40 | - * $QST_input_name |
|
41 | - * @access private |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - private $QST_input_name = ''; |
|
45 | - |
|
46 | - /** |
|
47 | - * $QST_input_id |
|
48 | - * @access private |
|
49 | - * @var string |
|
50 | - */ |
|
51 | - private $QST_input_id = ''; |
|
52 | - |
|
53 | - /** |
|
54 | - * $QST_input_class |
|
55 | - * @access private |
|
56 | - * @var string |
|
57 | - */ |
|
58 | - private $QST_input_class = ''; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var bool $QST_disabled |
|
62 | - */ |
|
63 | - private $QST_disabled = false; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * constructor for questions |
|
68 | - * |
|
69 | - * @param \EE_Question $QST EE_Question object |
|
70 | - * @param \EE_Answer $ANS EE_Answer object |
|
71 | - * @param array $q_meta |
|
72 | - * @access public |
|
73 | - * @return \EE_Question_Form_Input |
|
74 | - */ |
|
75 | - public function __construct(EE_Question $QST = null, EE_Answer $ANS = null, $q_meta = array()) |
|
76 | - { |
|
77 | - if (empty($QST) || empty($ANS)) { |
|
78 | - EE_Error::add_error( |
|
79 | - __('An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso'), |
|
80 | - __FILE__, |
|
81 | - __FUNCTION__, |
|
82 | - __LINE__ |
|
83 | - ); |
|
84 | - return null; |
|
85 | - } |
|
86 | - $this->_QST = $QST; |
|
87 | - $this->_ANS = $ANS; |
|
88 | - $this->set_question_form_input_meta($q_meta); |
|
89 | - $this->set_question_form_input_init(); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * sets meta data for the question form input |
|
95 | - * |
|
96 | - * @access public |
|
97 | - * @param array $q_meta |
|
98 | - * @return void |
|
99 | - */ |
|
100 | - public function set_question_form_input_meta($q_meta = array()) |
|
101 | - { |
|
102 | - $default_q_meta = array( |
|
103 | - 'att_nmbr' => 1, |
|
104 | - 'ticket_id' => '', |
|
105 | - 'date' => '', |
|
106 | - 'time' => '', |
|
107 | - 'input_name' => '', |
|
108 | - 'input_id' => '', |
|
109 | - 'input_class' => '', |
|
110 | - 'input_prefix' => 'qstn', |
|
111 | - 'append_qstn_id' => true, |
|
112 | - 'htmlentities' => true, |
|
113 | - 'allow_null' => false, |
|
114 | - ); |
|
115 | - $this->_QST_meta = array_merge($default_q_meta, $q_meta); |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * set_question_form_input_init |
|
121 | - * |
|
122 | - * @access public |
|
123 | - * @return void |
|
124 | - */ |
|
125 | - public function set_question_form_input_init() |
|
126 | - { |
|
127 | - $qstn_id = $this->_QST->system_ID() ? $this->_QST->system_ID() : $this->_QST->ID(); |
|
128 | - $this->_set_input_name($qstn_id); |
|
129 | - $this->_set_input_id($qstn_id); |
|
130 | - $this->_set_input_class($qstn_id); |
|
131 | - $this->set_question_form_input_answer($qstn_id); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * set_input_name |
|
137 | - * |
|
138 | - * @access private |
|
139 | - * @param $qstn_id |
|
140 | - * @return void |
|
141 | - */ |
|
142 | - private function _set_input_name($qstn_id) |
|
143 | - { |
|
144 | - if (! empty($qstn_id)) { |
|
145 | - $ANS_ID = $this->get('ANS_ID'); |
|
146 | - $qstn_id = ! empty($ANS_ID) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']'; |
|
147 | - } |
|
148 | - $this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
|
149 | - ? $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'] . $qstn_id |
|
150 | - : $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name']; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * get property values for question form input |
|
156 | - * |
|
157 | - * @access public |
|
158 | - * @param string $property |
|
159 | - * @return mixed |
|
160 | - */ |
|
161 | - public function get($property = null) |
|
162 | - { |
|
163 | - if (! empty($property)) { |
|
164 | - if (EEM_Question::instance()->has_field($property)) { |
|
165 | - return $this->_QST->get($property); |
|
166 | - } elseif (EEM_Answer::instance()->has_field($property)) { |
|
167 | - return $this->_ANS->get($property); |
|
168 | - } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) { |
|
169 | - return $this->{$property}; |
|
170 | - } |
|
171 | - } |
|
172 | - return null; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * _question_form_input_property_exists |
|
178 | - * |
|
179 | - * @access private |
|
180 | - * @param string $classname |
|
181 | - * @param string $property |
|
182 | - * @return boolean |
|
183 | - */ |
|
184 | - private function _question_form_input_property_exists($classname, $property) |
|
185 | - { |
|
186 | - // first try regular property exists method which works as expected in PHP 5.3+ |
|
187 | - $prop = EEH_Class_Tools::has_property($classname, $property); |
|
188 | - if (! $prop) { |
|
189 | - // use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction |
|
190 | - $reflector = new ReflectionClass($classname); |
|
191 | - $prop = $reflector->hasProperty($property); |
|
192 | - } |
|
193 | - return $prop; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * set_input_id |
|
199 | - * |
|
200 | - * @access private |
|
201 | - * @param $qstn_id |
|
202 | - * @return void |
|
203 | - */ |
|
204 | - private function _set_input_id($qstn_id) |
|
205 | - { |
|
206 | - $input_id = isset($this->_QST_meta['input_id']) && ! empty($this->_QST_meta['input_id']) |
|
207 | - ? $this->_QST_meta['input_id'] |
|
208 | - : sanitize_key(strip_tags($this->_QST->get('QST_display_text'))); |
|
209 | - $this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
|
210 | - ? $input_id . '-' . $qstn_id |
|
211 | - : $input_id; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * set_input_class |
|
217 | - * |
|
218 | - * @access private |
|
219 | - * @return void |
|
220 | - */ |
|
221 | - private function _set_input_class() |
|
222 | - { |
|
223 | - $this->QST_input_class = isset($this->_QST_meta['input_class']) ? $this->_QST_meta['input_class'] : ''; |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * set_question_form_input_answer |
|
229 | - * |
|
230 | - * @access public |
|
231 | - * @param mixed int | string $qstn_id |
|
232 | - * @return void |
|
233 | - */ |
|
234 | - public function set_question_form_input_answer($qstn_id) |
|
235 | - { |
|
236 | - // check for answer in $_REQUEST in case we are reprocessing a form after an error |
|
237 | - if (isset($this->_QST_meta['EVT_ID']) |
|
238 | - && isset($this->_QST_meta['att_nmbr']) |
|
239 | - && isset($this->_QST_meta['date']) |
|
240 | - && isset($this->_QST_meta['time']) |
|
241 | - && isset($this->_QST_meta['price_id']) |
|
242 | - ) { |
|
243 | - if (isset($_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]) |
|
244 | - ) { |
|
245 | - $answer = $_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]; |
|
246 | - $this->_ANS->set('ANS_value', $answer); |
|
247 | - } |
|
248 | - } |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * generate_question_form_inputs_for_object |
|
254 | - * |
|
255 | - * @access protected |
|
256 | - * @param bool|object $object $object |
|
257 | - * @param array $input_types |
|
258 | - * @return array |
|
259 | - */ |
|
260 | - public static function generate_question_form_inputs_for_object($object = false, $input_types = array()) |
|
261 | - { |
|
262 | - if (! is_object($object)) { |
|
263 | - return false; |
|
264 | - } |
|
265 | - $inputs = array(); |
|
266 | - $fields = $object->get_model()->field_settings(false); |
|
267 | - // $pk = $object->ID(); <<< NO! |
|
268 | - // EEH_Debug_Tools::printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
269 | - // EEH_Debug_Tools::printr( $fields, '$fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
270 | - // EEH_Debug_Tools::printr( $input_types, '$input_types <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
271 | - foreach ($fields as $field_ID => $field) { |
|
272 | - if ($field instanceof EE_Model_Field_Base) { |
|
273 | - // echo '<h4>$field_ID : ' . $field_ID . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
274 | - // EEH_Debug_Tools::printr( $field, '$field <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
275 | - if (isset($input_types[ $field_ID ])) { |
|
276 | - // get saved value for field |
|
277 | - $value = $object->get($field_ID); |
|
278 | - // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
279 | - // if no saved value, then use default |
|
280 | - $value = $value !== null ? $value : $field->get_default_value(); |
|
281 | - // if ( $field_ID == 'CNT_active' ) |
|
282 | - // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
283 | - // determine question type |
|
284 | - $type = isset($input_types[ $field_ID ]) ? $input_types[ $field_ID ]['type'] : 'TEXT'; |
|
285 | - // input name |
|
286 | - $input_name = isset($input_types[ $field_ID ]) && isset($input_types[ $field_ID ]['input_name']) |
|
287 | - ? $input_types[ $field_ID ]['input_name'] . '[' . $field_ID . ']' |
|
288 | - : $field_ID; |
|
289 | - // css class for input |
|
290 | - $class = isset($input_types[ $field_ID ]['class']) && ! empty($input_types[ $field_ID ]['class']) |
|
291 | - ? ' ' . $input_types[ $field_ID ]['class'] |
|
292 | - : ''; |
|
293 | - // whether to apply htmlentities to answer |
|
294 | - $htmlentities = isset($input_types[ $field_ID ]['htmlentities']) |
|
295 | - ? $input_types[ $field_ID ]['htmlentities'] |
|
296 | - : true; |
|
297 | - // whether to apply htmlentities to answer |
|
298 | - $label_b4 = isset($input_types[ $field_ID ]['label_b4']) |
|
299 | - ? $input_types[ $field_ID ]['label_b4'] |
|
300 | - : false; |
|
301 | - // whether to apply htmlentities to answer |
|
302 | - $use_desc_4_label = isset($input_types[ $field_ID ]['use_desc_4_label']) |
|
303 | - ? $input_types[ $field_ID ]['use_desc_4_label'] |
|
304 | - : false; |
|
305 | - // whether input is disabled |
|
306 | - $disabled = isset($input_types[ $field_ID ]['disabled']) |
|
307 | - ? $input_types[ $field_ID ]['disabled'] |
|
308 | - : false; |
|
309 | - |
|
310 | - // create EE_Question_Form_Input object |
|
311 | - $QFI = new EE_Question_Form_Input( |
|
312 | - EE_Question::new_instance( |
|
313 | - array( |
|
314 | - 'QST_ID' => 0, |
|
315 | - 'QST_display_text' => $field->get_nicename(), |
|
316 | - 'QST_type' => $type, |
|
317 | - ) |
|
318 | - ), |
|
319 | - EE_Answer::new_instance( |
|
320 | - array( |
|
321 | - 'ANS_ID' => 0, |
|
322 | - 'QST_ID' => 0, |
|
323 | - 'REG_ID' => 0, |
|
324 | - 'ANS_value' => $value, |
|
325 | - ) |
|
326 | - ), |
|
327 | - array( |
|
328 | - 'input_id' => $field_ID . '-' . $object->ID(), |
|
329 | - 'input_name' => $input_name, |
|
330 | - 'input_class' => $field_ID . $class, |
|
331 | - 'input_prefix' => '', |
|
332 | - 'append_qstn_id' => false, |
|
333 | - 'htmlentities' => $htmlentities, |
|
334 | - 'label_b4' => $label_b4, |
|
335 | - 'use_desc_4_label' => $use_desc_4_label, |
|
336 | - ) |
|
337 | - ); |
|
338 | - // does question type have options ? |
|
339 | - if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX')) |
|
340 | - && isset($input_types[ $field_ID ]) |
|
341 | - && isset($input_types[ $field_ID ]['options']) |
|
342 | - ) { |
|
343 | - foreach ($input_types[ $field_ID ]['options'] as $option) { |
|
344 | - $option = stripslashes_deep($option); |
|
345 | - $option_id = ! empty($option['id']) ? $option['id'] : 0; |
|
346 | - $QSO = EE_Question_Option::new_instance( |
|
347 | - array( |
|
348 | - 'QSO_value' => (string) $option_id, |
|
349 | - 'QSO_desc' => $option['text'], |
|
350 | - 'QSO_deleted' => false, |
|
351 | - ) |
|
352 | - ); |
|
353 | - // all QST (and ANS) properties can be accessed indirectly thru QFI |
|
354 | - $QFI->add_temp_option($QSO); |
|
355 | - } |
|
356 | - } |
|
357 | - // we don't want ppl manually changing primary keys cuz that would just lead to total craziness man |
|
358 | - if ($disabled || $field_ID == $object->get_model()->primary_key_name()) { |
|
359 | - $QFI->set('QST_disabled', true); |
|
360 | - } |
|
361 | - // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
362 | - $inputs[ $field_ID ] = $QFI; |
|
363 | - // if ( $field_ID == 'CNT_active' ) { |
|
364 | - // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
365 | - // } |
|
366 | - } |
|
367 | - } |
|
368 | - } |
|
369 | - return $inputs; |
|
370 | - } |
|
371 | - |
|
372 | - |
|
373 | - /** |
|
374 | - * add_temp_option |
|
375 | - * |
|
376 | - * @access public |
|
377 | - * @param \EE_Question_Option $QSO EE_Question_Option |
|
378 | - * @return boolean |
|
379 | - */ |
|
380 | - public function add_temp_option(EE_Question_Option $QSO) |
|
381 | - { |
|
382 | - $this->_QST->add_temp_option($QSO); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * set property values for question form input |
|
388 | - * |
|
389 | - * @access public |
|
390 | - * @param string $property |
|
391 | - * @param mixed $value |
|
392 | - * @return mixed |
|
393 | - */ |
|
394 | - public function set($property = null, $value = null) |
|
395 | - { |
|
396 | - if (! empty($property)) { |
|
397 | - if (EEM_Question::instance()->has_field($property)) { |
|
398 | - $this->_QST->set($property, $value); |
|
399 | - } elseif (EEM_Answer::instance()->has_field($property)) { |
|
400 | - $this->_ANS->set($property, $value); |
|
401 | - } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) { |
|
402 | - // echo "<hr>$property is a prop of QFI"; |
|
403 | - $this->{$property} = $value; |
|
404 | - return true; |
|
405 | - } |
|
406 | - } |
|
407 | - return null; |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - /** |
|
412 | - * _question_form_input_property_exists |
|
413 | - * |
|
414 | - * @access public |
|
415 | - * @param boolean $notDeletedOptionsOnly 1 |
|
416 | - * whether to return ALL options, or only the ones which have |
|
417 | - * not yet been deleted |
|
418 | - * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
419 | - * we want to usually only show non-deleted options AND the |
|
420 | - * value that was selected for the answer, whether it was |
|
421 | - * trashed or not. |
|
422 | - * @return EE_Question_Option |
|
423 | - */ |
|
424 | - public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
425 | - { |
|
426 | - $temp_options = $this->_QST->temp_options(); |
|
427 | - return ! empty($temp_options) |
|
428 | - ? $temp_options |
|
429 | - : $this->_QST->options( |
|
430 | - $notDeletedOptionsOnly, |
|
431 | - $selected_value_to_always_include |
|
432 | - ); |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * get_meta |
|
438 | - * |
|
439 | - * @access public |
|
440 | - * @param mixed $key |
|
441 | - * @return mixed |
|
442 | - */ |
|
443 | - public function get_meta($key = false) |
|
444 | - { |
|
445 | - return $key && isset($this->_QST_meta[ $key ]) ? $this->_QST_meta[ $key ] : false; |
|
446 | - } |
|
16 | + /** |
|
17 | + * EE_Question object |
|
18 | + * |
|
19 | + * @access private |
|
20 | + * @var object |
|
21 | + */ |
|
22 | + private $_QST = null; |
|
23 | + |
|
24 | + /** |
|
25 | + * EE_Answer object |
|
26 | + * |
|
27 | + * @access private |
|
28 | + * @var object |
|
29 | + */ |
|
30 | + private $_ANS = null; |
|
31 | + |
|
32 | + /** |
|
33 | + * $_QST_meta |
|
34 | + * @access private |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + private $_QST_meta = array(); |
|
38 | + |
|
39 | + /** |
|
40 | + * $QST_input_name |
|
41 | + * @access private |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + private $QST_input_name = ''; |
|
45 | + |
|
46 | + /** |
|
47 | + * $QST_input_id |
|
48 | + * @access private |
|
49 | + * @var string |
|
50 | + */ |
|
51 | + private $QST_input_id = ''; |
|
52 | + |
|
53 | + /** |
|
54 | + * $QST_input_class |
|
55 | + * @access private |
|
56 | + * @var string |
|
57 | + */ |
|
58 | + private $QST_input_class = ''; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var bool $QST_disabled |
|
62 | + */ |
|
63 | + private $QST_disabled = false; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * constructor for questions |
|
68 | + * |
|
69 | + * @param \EE_Question $QST EE_Question object |
|
70 | + * @param \EE_Answer $ANS EE_Answer object |
|
71 | + * @param array $q_meta |
|
72 | + * @access public |
|
73 | + * @return \EE_Question_Form_Input |
|
74 | + */ |
|
75 | + public function __construct(EE_Question $QST = null, EE_Answer $ANS = null, $q_meta = array()) |
|
76 | + { |
|
77 | + if (empty($QST) || empty($ANS)) { |
|
78 | + EE_Error::add_error( |
|
79 | + __('An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso'), |
|
80 | + __FILE__, |
|
81 | + __FUNCTION__, |
|
82 | + __LINE__ |
|
83 | + ); |
|
84 | + return null; |
|
85 | + } |
|
86 | + $this->_QST = $QST; |
|
87 | + $this->_ANS = $ANS; |
|
88 | + $this->set_question_form_input_meta($q_meta); |
|
89 | + $this->set_question_form_input_init(); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * sets meta data for the question form input |
|
95 | + * |
|
96 | + * @access public |
|
97 | + * @param array $q_meta |
|
98 | + * @return void |
|
99 | + */ |
|
100 | + public function set_question_form_input_meta($q_meta = array()) |
|
101 | + { |
|
102 | + $default_q_meta = array( |
|
103 | + 'att_nmbr' => 1, |
|
104 | + 'ticket_id' => '', |
|
105 | + 'date' => '', |
|
106 | + 'time' => '', |
|
107 | + 'input_name' => '', |
|
108 | + 'input_id' => '', |
|
109 | + 'input_class' => '', |
|
110 | + 'input_prefix' => 'qstn', |
|
111 | + 'append_qstn_id' => true, |
|
112 | + 'htmlentities' => true, |
|
113 | + 'allow_null' => false, |
|
114 | + ); |
|
115 | + $this->_QST_meta = array_merge($default_q_meta, $q_meta); |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * set_question_form_input_init |
|
121 | + * |
|
122 | + * @access public |
|
123 | + * @return void |
|
124 | + */ |
|
125 | + public function set_question_form_input_init() |
|
126 | + { |
|
127 | + $qstn_id = $this->_QST->system_ID() ? $this->_QST->system_ID() : $this->_QST->ID(); |
|
128 | + $this->_set_input_name($qstn_id); |
|
129 | + $this->_set_input_id($qstn_id); |
|
130 | + $this->_set_input_class($qstn_id); |
|
131 | + $this->set_question_form_input_answer($qstn_id); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * set_input_name |
|
137 | + * |
|
138 | + * @access private |
|
139 | + * @param $qstn_id |
|
140 | + * @return void |
|
141 | + */ |
|
142 | + private function _set_input_name($qstn_id) |
|
143 | + { |
|
144 | + if (! empty($qstn_id)) { |
|
145 | + $ANS_ID = $this->get('ANS_ID'); |
|
146 | + $qstn_id = ! empty($ANS_ID) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']'; |
|
147 | + } |
|
148 | + $this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
|
149 | + ? $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'] . $qstn_id |
|
150 | + : $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name']; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * get property values for question form input |
|
156 | + * |
|
157 | + * @access public |
|
158 | + * @param string $property |
|
159 | + * @return mixed |
|
160 | + */ |
|
161 | + public function get($property = null) |
|
162 | + { |
|
163 | + if (! empty($property)) { |
|
164 | + if (EEM_Question::instance()->has_field($property)) { |
|
165 | + return $this->_QST->get($property); |
|
166 | + } elseif (EEM_Answer::instance()->has_field($property)) { |
|
167 | + return $this->_ANS->get($property); |
|
168 | + } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) { |
|
169 | + return $this->{$property}; |
|
170 | + } |
|
171 | + } |
|
172 | + return null; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * _question_form_input_property_exists |
|
178 | + * |
|
179 | + * @access private |
|
180 | + * @param string $classname |
|
181 | + * @param string $property |
|
182 | + * @return boolean |
|
183 | + */ |
|
184 | + private function _question_form_input_property_exists($classname, $property) |
|
185 | + { |
|
186 | + // first try regular property exists method which works as expected in PHP 5.3+ |
|
187 | + $prop = EEH_Class_Tools::has_property($classname, $property); |
|
188 | + if (! $prop) { |
|
189 | + // use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction |
|
190 | + $reflector = new ReflectionClass($classname); |
|
191 | + $prop = $reflector->hasProperty($property); |
|
192 | + } |
|
193 | + return $prop; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * set_input_id |
|
199 | + * |
|
200 | + * @access private |
|
201 | + * @param $qstn_id |
|
202 | + * @return void |
|
203 | + */ |
|
204 | + private function _set_input_id($qstn_id) |
|
205 | + { |
|
206 | + $input_id = isset($this->_QST_meta['input_id']) && ! empty($this->_QST_meta['input_id']) |
|
207 | + ? $this->_QST_meta['input_id'] |
|
208 | + : sanitize_key(strip_tags($this->_QST->get('QST_display_text'))); |
|
209 | + $this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
|
210 | + ? $input_id . '-' . $qstn_id |
|
211 | + : $input_id; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * set_input_class |
|
217 | + * |
|
218 | + * @access private |
|
219 | + * @return void |
|
220 | + */ |
|
221 | + private function _set_input_class() |
|
222 | + { |
|
223 | + $this->QST_input_class = isset($this->_QST_meta['input_class']) ? $this->_QST_meta['input_class'] : ''; |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * set_question_form_input_answer |
|
229 | + * |
|
230 | + * @access public |
|
231 | + * @param mixed int | string $qstn_id |
|
232 | + * @return void |
|
233 | + */ |
|
234 | + public function set_question_form_input_answer($qstn_id) |
|
235 | + { |
|
236 | + // check for answer in $_REQUEST in case we are reprocessing a form after an error |
|
237 | + if (isset($this->_QST_meta['EVT_ID']) |
|
238 | + && isset($this->_QST_meta['att_nmbr']) |
|
239 | + && isset($this->_QST_meta['date']) |
|
240 | + && isset($this->_QST_meta['time']) |
|
241 | + && isset($this->_QST_meta['price_id']) |
|
242 | + ) { |
|
243 | + if (isset($_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]) |
|
244 | + ) { |
|
245 | + $answer = $_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]; |
|
246 | + $this->_ANS->set('ANS_value', $answer); |
|
247 | + } |
|
248 | + } |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * generate_question_form_inputs_for_object |
|
254 | + * |
|
255 | + * @access protected |
|
256 | + * @param bool|object $object $object |
|
257 | + * @param array $input_types |
|
258 | + * @return array |
|
259 | + */ |
|
260 | + public static function generate_question_form_inputs_for_object($object = false, $input_types = array()) |
|
261 | + { |
|
262 | + if (! is_object($object)) { |
|
263 | + return false; |
|
264 | + } |
|
265 | + $inputs = array(); |
|
266 | + $fields = $object->get_model()->field_settings(false); |
|
267 | + // $pk = $object->ID(); <<< NO! |
|
268 | + // EEH_Debug_Tools::printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
269 | + // EEH_Debug_Tools::printr( $fields, '$fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
270 | + // EEH_Debug_Tools::printr( $input_types, '$input_types <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
271 | + foreach ($fields as $field_ID => $field) { |
|
272 | + if ($field instanceof EE_Model_Field_Base) { |
|
273 | + // echo '<h4>$field_ID : ' . $field_ID . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
274 | + // EEH_Debug_Tools::printr( $field, '$field <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
275 | + if (isset($input_types[ $field_ID ])) { |
|
276 | + // get saved value for field |
|
277 | + $value = $object->get($field_ID); |
|
278 | + // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
279 | + // if no saved value, then use default |
|
280 | + $value = $value !== null ? $value : $field->get_default_value(); |
|
281 | + // if ( $field_ID == 'CNT_active' ) |
|
282 | + // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
|
283 | + // determine question type |
|
284 | + $type = isset($input_types[ $field_ID ]) ? $input_types[ $field_ID ]['type'] : 'TEXT'; |
|
285 | + // input name |
|
286 | + $input_name = isset($input_types[ $field_ID ]) && isset($input_types[ $field_ID ]['input_name']) |
|
287 | + ? $input_types[ $field_ID ]['input_name'] . '[' . $field_ID . ']' |
|
288 | + : $field_ID; |
|
289 | + // css class for input |
|
290 | + $class = isset($input_types[ $field_ID ]['class']) && ! empty($input_types[ $field_ID ]['class']) |
|
291 | + ? ' ' . $input_types[ $field_ID ]['class'] |
|
292 | + : ''; |
|
293 | + // whether to apply htmlentities to answer |
|
294 | + $htmlentities = isset($input_types[ $field_ID ]['htmlentities']) |
|
295 | + ? $input_types[ $field_ID ]['htmlentities'] |
|
296 | + : true; |
|
297 | + // whether to apply htmlentities to answer |
|
298 | + $label_b4 = isset($input_types[ $field_ID ]['label_b4']) |
|
299 | + ? $input_types[ $field_ID ]['label_b4'] |
|
300 | + : false; |
|
301 | + // whether to apply htmlentities to answer |
|
302 | + $use_desc_4_label = isset($input_types[ $field_ID ]['use_desc_4_label']) |
|
303 | + ? $input_types[ $field_ID ]['use_desc_4_label'] |
|
304 | + : false; |
|
305 | + // whether input is disabled |
|
306 | + $disabled = isset($input_types[ $field_ID ]['disabled']) |
|
307 | + ? $input_types[ $field_ID ]['disabled'] |
|
308 | + : false; |
|
309 | + |
|
310 | + // create EE_Question_Form_Input object |
|
311 | + $QFI = new EE_Question_Form_Input( |
|
312 | + EE_Question::new_instance( |
|
313 | + array( |
|
314 | + 'QST_ID' => 0, |
|
315 | + 'QST_display_text' => $field->get_nicename(), |
|
316 | + 'QST_type' => $type, |
|
317 | + ) |
|
318 | + ), |
|
319 | + EE_Answer::new_instance( |
|
320 | + array( |
|
321 | + 'ANS_ID' => 0, |
|
322 | + 'QST_ID' => 0, |
|
323 | + 'REG_ID' => 0, |
|
324 | + 'ANS_value' => $value, |
|
325 | + ) |
|
326 | + ), |
|
327 | + array( |
|
328 | + 'input_id' => $field_ID . '-' . $object->ID(), |
|
329 | + 'input_name' => $input_name, |
|
330 | + 'input_class' => $field_ID . $class, |
|
331 | + 'input_prefix' => '', |
|
332 | + 'append_qstn_id' => false, |
|
333 | + 'htmlentities' => $htmlentities, |
|
334 | + 'label_b4' => $label_b4, |
|
335 | + 'use_desc_4_label' => $use_desc_4_label, |
|
336 | + ) |
|
337 | + ); |
|
338 | + // does question type have options ? |
|
339 | + if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX')) |
|
340 | + && isset($input_types[ $field_ID ]) |
|
341 | + && isset($input_types[ $field_ID ]['options']) |
|
342 | + ) { |
|
343 | + foreach ($input_types[ $field_ID ]['options'] as $option) { |
|
344 | + $option = stripslashes_deep($option); |
|
345 | + $option_id = ! empty($option['id']) ? $option['id'] : 0; |
|
346 | + $QSO = EE_Question_Option::new_instance( |
|
347 | + array( |
|
348 | + 'QSO_value' => (string) $option_id, |
|
349 | + 'QSO_desc' => $option['text'], |
|
350 | + 'QSO_deleted' => false, |
|
351 | + ) |
|
352 | + ); |
|
353 | + // all QST (and ANS) properties can be accessed indirectly thru QFI |
|
354 | + $QFI->add_temp_option($QSO); |
|
355 | + } |
|
356 | + } |
|
357 | + // we don't want ppl manually changing primary keys cuz that would just lead to total craziness man |
|
358 | + if ($disabled || $field_ID == $object->get_model()->primary_key_name()) { |
|
359 | + $QFI->set('QST_disabled', true); |
|
360 | + } |
|
361 | + // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
362 | + $inputs[ $field_ID ] = $QFI; |
|
363 | + // if ( $field_ID == 'CNT_active' ) { |
|
364 | + // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
|
365 | + // } |
|
366 | + } |
|
367 | + } |
|
368 | + } |
|
369 | + return $inputs; |
|
370 | + } |
|
371 | + |
|
372 | + |
|
373 | + /** |
|
374 | + * add_temp_option |
|
375 | + * |
|
376 | + * @access public |
|
377 | + * @param \EE_Question_Option $QSO EE_Question_Option |
|
378 | + * @return boolean |
|
379 | + */ |
|
380 | + public function add_temp_option(EE_Question_Option $QSO) |
|
381 | + { |
|
382 | + $this->_QST->add_temp_option($QSO); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * set property values for question form input |
|
388 | + * |
|
389 | + * @access public |
|
390 | + * @param string $property |
|
391 | + * @param mixed $value |
|
392 | + * @return mixed |
|
393 | + */ |
|
394 | + public function set($property = null, $value = null) |
|
395 | + { |
|
396 | + if (! empty($property)) { |
|
397 | + if (EEM_Question::instance()->has_field($property)) { |
|
398 | + $this->_QST->set($property, $value); |
|
399 | + } elseif (EEM_Answer::instance()->has_field($property)) { |
|
400 | + $this->_ANS->set($property, $value); |
|
401 | + } elseif ($this->_question_form_input_property_exists(__CLASS__, $property)) { |
|
402 | + // echo "<hr>$property is a prop of QFI"; |
|
403 | + $this->{$property} = $value; |
|
404 | + return true; |
|
405 | + } |
|
406 | + } |
|
407 | + return null; |
|
408 | + } |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * _question_form_input_property_exists |
|
413 | + * |
|
414 | + * @access public |
|
415 | + * @param boolean $notDeletedOptionsOnly 1 |
|
416 | + * whether to return ALL options, or only the ones which have |
|
417 | + * not yet been deleted |
|
418 | + * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
419 | + * we want to usually only show non-deleted options AND the |
|
420 | + * value that was selected for the answer, whether it was |
|
421 | + * trashed or not. |
|
422 | + * @return EE_Question_Option |
|
423 | + */ |
|
424 | + public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
425 | + { |
|
426 | + $temp_options = $this->_QST->temp_options(); |
|
427 | + return ! empty($temp_options) |
|
428 | + ? $temp_options |
|
429 | + : $this->_QST->options( |
|
430 | + $notDeletedOptionsOnly, |
|
431 | + $selected_value_to_always_include |
|
432 | + ); |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * get_meta |
|
438 | + * |
|
439 | + * @access public |
|
440 | + * @param mixed $key |
|
441 | + * @return mixed |
|
442 | + */ |
|
443 | + public function get_meta($key = false) |
|
444 | + { |
|
445 | + return $key && isset($this->_QST_meta[ $key ]) ? $this->_QST_meta[ $key ] : false; |
|
446 | + } |
|
447 | 447 | } |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | */ |
142 | 142 | private function _set_input_name($qstn_id) |
143 | 143 | { |
144 | - if (! empty($qstn_id)) { |
|
144 | + if ( ! empty($qstn_id)) { |
|
145 | 145 | $ANS_ID = $this->get('ANS_ID'); |
146 | - $qstn_id = ! empty($ANS_ID) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']'; |
|
146 | + $qstn_id = ! empty($ANS_ID) ? '['.$qstn_id.']['.$ANS_ID.']' : '['.$qstn_id.']'; |
|
147 | 147 | } |
148 | 148 | $this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
149 | - ? $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name'] . $qstn_id |
|
150 | - : $this->_QST_meta['input_prefix'] . $this->_QST_meta['input_name']; |
|
149 | + ? $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name'].$qstn_id |
|
150 | + : $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name']; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get($property = null) |
162 | 162 | { |
163 | - if (! empty($property)) { |
|
163 | + if ( ! empty($property)) { |
|
164 | 164 | if (EEM_Question::instance()->has_field($property)) { |
165 | 165 | return $this->_QST->get($property); |
166 | 166 | } elseif (EEM_Answer::instance()->has_field($property)) { |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | { |
186 | 186 | // first try regular property exists method which works as expected in PHP 5.3+ |
187 | 187 | $prop = EEH_Class_Tools::has_property($classname, $property); |
188 | - if (! $prop) { |
|
188 | + if ( ! $prop) { |
|
189 | 189 | // use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction |
190 | 190 | $reflector = new ReflectionClass($classname); |
191 | 191 | $prop = $reflector->hasProperty($property); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ? $this->_QST_meta['input_id'] |
208 | 208 | : sanitize_key(strip_tags($this->_QST->get('QST_display_text'))); |
209 | 209 | $this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) |
210 | - ? $input_id . '-' . $qstn_id |
|
210 | + ? $input_id.'-'.$qstn_id |
|
211 | 211 | : $input_id; |
212 | 212 | } |
213 | 213 | |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | && isset($this->_QST_meta['time']) |
241 | 241 | && isset($this->_QST_meta['price_id']) |
242 | 242 | ) { |
243 | - if (isset($_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]) |
|
243 | + if (isset($_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id]) |
|
244 | 244 | ) { |
245 | - $answer = $_REQUEST['qstn'][ $this->_QST_meta['EVT_ID'] ][ $this->_QST_meta['att_nmbr'] ][ $this->_QST_meta['date'] ][ $this->_QST_meta['time'] ][ $this->_QST_meta['price_id'] ][ $qstn_id ]; |
|
245 | + $answer = $_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id]; |
|
246 | 246 | $this->_ANS->set('ANS_value', $answer); |
247 | 247 | } |
248 | 248 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public static function generate_question_form_inputs_for_object($object = false, $input_types = array()) |
261 | 261 | { |
262 | - if (! is_object($object)) { |
|
262 | + if ( ! is_object($object)) { |
|
263 | 263 | return false; |
264 | 264 | } |
265 | 265 | $inputs = array(); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | if ($field instanceof EE_Model_Field_Base) { |
273 | 273 | // echo '<h4>$field_ID : ' . $field_ID . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
274 | 274 | // EEH_Debug_Tools::printr( $field, '$field <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
275 | - if (isset($input_types[ $field_ID ])) { |
|
275 | + if (isset($input_types[$field_ID])) { |
|
276 | 276 | // get saved value for field |
277 | 277 | $value = $object->get($field_ID); |
278 | 278 | // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
@@ -281,30 +281,30 @@ discard block |
||
281 | 281 | // if ( $field_ID == 'CNT_active' ) |
282 | 282 | // echo '<h4>$value : ' . $value . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>'; |
283 | 283 | // determine question type |
284 | - $type = isset($input_types[ $field_ID ]) ? $input_types[ $field_ID ]['type'] : 'TEXT'; |
|
284 | + $type = isset($input_types[$field_ID]) ? $input_types[$field_ID]['type'] : 'TEXT'; |
|
285 | 285 | // input name |
286 | - $input_name = isset($input_types[ $field_ID ]) && isset($input_types[ $field_ID ]['input_name']) |
|
287 | - ? $input_types[ $field_ID ]['input_name'] . '[' . $field_ID . ']' |
|
286 | + $input_name = isset($input_types[$field_ID]) && isset($input_types[$field_ID]['input_name']) |
|
287 | + ? $input_types[$field_ID]['input_name'].'['.$field_ID.']' |
|
288 | 288 | : $field_ID; |
289 | 289 | // css class for input |
290 | - $class = isset($input_types[ $field_ID ]['class']) && ! empty($input_types[ $field_ID ]['class']) |
|
291 | - ? ' ' . $input_types[ $field_ID ]['class'] |
|
290 | + $class = isset($input_types[$field_ID]['class']) && ! empty($input_types[$field_ID]['class']) |
|
291 | + ? ' '.$input_types[$field_ID]['class'] |
|
292 | 292 | : ''; |
293 | 293 | // whether to apply htmlentities to answer |
294 | - $htmlentities = isset($input_types[ $field_ID ]['htmlentities']) |
|
295 | - ? $input_types[ $field_ID ]['htmlentities'] |
|
294 | + $htmlentities = isset($input_types[$field_ID]['htmlentities']) |
|
295 | + ? $input_types[$field_ID]['htmlentities'] |
|
296 | 296 | : true; |
297 | 297 | // whether to apply htmlentities to answer |
298 | - $label_b4 = isset($input_types[ $field_ID ]['label_b4']) |
|
299 | - ? $input_types[ $field_ID ]['label_b4'] |
|
298 | + $label_b4 = isset($input_types[$field_ID]['label_b4']) |
|
299 | + ? $input_types[$field_ID]['label_b4'] |
|
300 | 300 | : false; |
301 | 301 | // whether to apply htmlentities to answer |
302 | - $use_desc_4_label = isset($input_types[ $field_ID ]['use_desc_4_label']) |
|
303 | - ? $input_types[ $field_ID ]['use_desc_4_label'] |
|
302 | + $use_desc_4_label = isset($input_types[$field_ID]['use_desc_4_label']) |
|
303 | + ? $input_types[$field_ID]['use_desc_4_label'] |
|
304 | 304 | : false; |
305 | 305 | // whether input is disabled |
306 | - $disabled = isset($input_types[ $field_ID ]['disabled']) |
|
307 | - ? $input_types[ $field_ID ]['disabled'] |
|
306 | + $disabled = isset($input_types[$field_ID]['disabled']) |
|
307 | + ? $input_types[$field_ID]['disabled'] |
|
308 | 308 | : false; |
309 | 309 | |
310 | 310 | // create EE_Question_Form_Input object |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | ) |
326 | 326 | ), |
327 | 327 | array( |
328 | - 'input_id' => $field_ID . '-' . $object->ID(), |
|
328 | + 'input_id' => $field_ID.'-'.$object->ID(), |
|
329 | 329 | 'input_name' => $input_name, |
330 | - 'input_class' => $field_ID . $class, |
|
330 | + 'input_class' => $field_ID.$class, |
|
331 | 331 | 'input_prefix' => '', |
332 | 332 | 'append_qstn_id' => false, |
333 | 333 | 'htmlentities' => $htmlentities, |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | ); |
338 | 338 | // does question type have options ? |
339 | 339 | if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX')) |
340 | - && isset($input_types[ $field_ID ]) |
|
341 | - && isset($input_types[ $field_ID ]['options']) |
|
340 | + && isset($input_types[$field_ID]) |
|
341 | + && isset($input_types[$field_ID]['options']) |
|
342 | 342 | ) { |
343 | - foreach ($input_types[ $field_ID ]['options'] as $option) { |
|
343 | + foreach ($input_types[$field_ID]['options'] as $option) { |
|
344 | 344 | $option = stripslashes_deep($option); |
345 | 345 | $option_id = ! empty($option['id']) ? $option['id'] : 0; |
346 | 346 | $QSO = EE_Question_Option::new_instance( |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | $QFI->set('QST_disabled', true); |
360 | 360 | } |
361 | 361 | // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
362 | - $inputs[ $field_ID ] = $QFI; |
|
362 | + $inputs[$field_ID] = $QFI; |
|
363 | 363 | // if ( $field_ID == 'CNT_active' ) { |
364 | 364 | // EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
365 | 365 | // } |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | */ |
394 | 394 | public function set($property = null, $value = null) |
395 | 395 | { |
396 | - if (! empty($property)) { |
|
396 | + if ( ! empty($property)) { |
|
397 | 397 | if (EEM_Question::instance()->has_field($property)) { |
398 | 398 | $this->_QST->set($property, $value); |
399 | 399 | } elseif (EEM_Answer::instance()->has_field($property)) { |
@@ -442,6 +442,6 @@ discard block |
||
442 | 442 | */ |
443 | 443 | public function get_meta($key = false) |
444 | 444 | { |
445 | - return $key && isset($this->_QST_meta[ $key ]) ? $this->_QST_meta[ $key ] : false; |
|
445 | + return $key && isset($this->_QST_meta[$key]) ? $this->_QST_meta[$key] : false; |
|
446 | 446 | } |
447 | 447 | } |
@@ -40,506 +40,506 @@ |
||
40 | 40 | class OrganizationSettings extends FormHandler |
41 | 41 | { |
42 | 42 | |
43 | - /** |
|
44 | - * @var EE_Organization_Config |
|
45 | - */ |
|
46 | - protected $organization_config; |
|
43 | + /** |
|
44 | + * @var EE_Organization_Config |
|
45 | + */ |
|
46 | + protected $organization_config; |
|
47 | 47 | |
48 | - /** |
|
49 | - * @var EE_Core_Config |
|
50 | - */ |
|
51 | - protected $core_config; |
|
48 | + /** |
|
49 | + * @var EE_Core_Config |
|
50 | + */ |
|
51 | + protected $core_config; |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * @var EE_Network_Core_Config |
|
56 | - */ |
|
57 | - protected $network_core_config; |
|
54 | + /** |
|
55 | + * @var EE_Network_Core_Config |
|
56 | + */ |
|
57 | + protected $network_core_config; |
|
58 | 58 | |
59 | - /** |
|
60 | - * Form constructor. |
|
61 | - * |
|
62 | - * @param EE_Registry $registry |
|
63 | - * @param EE_Organization_Config $organization_config |
|
64 | - * @param EE_Core_Config $core_config |
|
65 | - * @param EE_Network_Core_Config $network_core_config |
|
66 | - * @throws InvalidArgumentException |
|
67 | - * @throws InvalidDataTypeException |
|
68 | - * @throws DomainException |
|
69 | - */ |
|
70 | - public function __construct( |
|
71 | - EE_Registry $registry, |
|
72 | - EE_Organization_Config $organization_config, |
|
73 | - EE_Core_Config $core_config, |
|
74 | - EE_Network_Core_Config $network_core_config |
|
75 | - ) { |
|
76 | - $this->organization_config = $organization_config; |
|
77 | - $this->core_config = $core_config; |
|
78 | - $this->network_core_config = $network_core_config; |
|
79 | - parent::__construct( |
|
80 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
81 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
82 | - 'organization_settings', |
|
83 | - '', |
|
84 | - FormHandler::DO_NOT_SETUP_FORM, |
|
85 | - $registry |
|
86 | - ); |
|
87 | - } |
|
59 | + /** |
|
60 | + * Form constructor. |
|
61 | + * |
|
62 | + * @param EE_Registry $registry |
|
63 | + * @param EE_Organization_Config $organization_config |
|
64 | + * @param EE_Core_Config $core_config |
|
65 | + * @param EE_Network_Core_Config $network_core_config |
|
66 | + * @throws InvalidArgumentException |
|
67 | + * @throws InvalidDataTypeException |
|
68 | + * @throws DomainException |
|
69 | + */ |
|
70 | + public function __construct( |
|
71 | + EE_Registry $registry, |
|
72 | + EE_Organization_Config $organization_config, |
|
73 | + EE_Core_Config $core_config, |
|
74 | + EE_Network_Core_Config $network_core_config |
|
75 | + ) { |
|
76 | + $this->organization_config = $organization_config; |
|
77 | + $this->core_config = $core_config; |
|
78 | + $this->network_core_config = $network_core_config; |
|
79 | + parent::__construct( |
|
80 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
81 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
82 | + 'organization_settings', |
|
83 | + '', |
|
84 | + FormHandler::DO_NOT_SETUP_FORM, |
|
85 | + $registry |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * creates and returns the actual form |
|
93 | - * |
|
94 | - * @return EE_Form_Section_Proper |
|
95 | - * @throws EE_Error |
|
96 | - */ |
|
97 | - public function generate() |
|
98 | - { |
|
99 | - $form = new EE_Form_Section_Proper( |
|
100 | - array( |
|
101 | - 'name' => 'organization_settings', |
|
102 | - 'html_id' => 'organization_settings', |
|
103 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
104 | - 'subsections' => array( |
|
105 | - 'contact_information_hdr' => new EE_Form_Section_HTML( |
|
106 | - EEH_HTML::h2( |
|
107 | - esc_html__('Contact Information', 'event_espresso') |
|
108 | - . ' ' |
|
109 | - . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')), |
|
110 | - '', |
|
111 | - 'contact-information-hdr' |
|
112 | - ) |
|
113 | - ), |
|
114 | - 'organization_name' => new EE_Text_Input( |
|
115 | - array( |
|
116 | - 'html_name' => 'organization_name', |
|
117 | - 'html_label_text' => esc_html__('Organization Name', 'event_espresso'), |
|
118 | - 'html_help_text' => esc_html__( |
|
119 | - 'Displayed on all emails and invoices.', |
|
120 | - 'event_espresso' |
|
121 | - ), |
|
122 | - 'default' => $this->organization_config->get_pretty('name'), |
|
123 | - 'required' => false, |
|
124 | - ) |
|
125 | - ), |
|
126 | - 'organization_address_1' => new EE_Text_Input( |
|
127 | - array( |
|
128 | - 'html_name' => 'organization_address_1', |
|
129 | - 'html_label_text' => esc_html__('Street Address', 'event_espresso'), |
|
130 | - 'default' => $this->organization_config->get_pretty('address_1'), |
|
131 | - 'required' => false, |
|
132 | - ) |
|
133 | - ), |
|
134 | - 'organization_address_2' => new EE_Text_Input( |
|
135 | - array( |
|
136 | - 'html_name' => 'organization_address_2', |
|
137 | - 'html_label_text' => esc_html__('Street Address 2', 'event_espresso'), |
|
138 | - 'default' => $this->organization_config->get_pretty('address_2'), |
|
139 | - 'required' => false, |
|
140 | - ) |
|
141 | - ), |
|
142 | - 'organization_city' => new EE_Text_Input( |
|
143 | - array( |
|
144 | - 'html_name' => 'organization_city', |
|
145 | - 'html_label_text' => esc_html__('City', 'event_espresso'), |
|
146 | - 'default' => $this->organization_config->get_pretty('city'), |
|
147 | - 'required' => false, |
|
148 | - ) |
|
149 | - ), |
|
150 | - 'organization_state' => new EE_State_Select_Input( |
|
151 | - null, |
|
152 | - array( |
|
153 | - 'html_name' => 'organization_state', |
|
154 | - 'html_label_text' => esc_html__('State/Province', 'event_espresso'), |
|
155 | - 'default' => $this->organization_config->STA_ID, |
|
156 | - 'required' => false, |
|
157 | - ) |
|
158 | - ), |
|
159 | - 'organization_country' => new EE_Country_Select_Input( |
|
160 | - null, |
|
161 | - array( |
|
162 | - 'html_name' => 'organization_country', |
|
163 | - 'html_label_text' => esc_html__('Country', 'event_espresso'), |
|
164 | - 'default' => $this->organization_config->CNT_ISO, |
|
165 | - 'required' => false, |
|
166 | - 'html_help_text' => sprintf( |
|
167 | - esc_html__( |
|
168 | - '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s', |
|
169 | - 'event_espresso' |
|
170 | - ), |
|
171 | - '<span class="reminder-spn">', |
|
172 | - '</span>' |
|
173 | - ), |
|
174 | - ) |
|
175 | - ), |
|
176 | - 'organization_zip' => new EE_Text_Input( |
|
177 | - array( |
|
178 | - 'html_name' => 'organization_zip', |
|
179 | - 'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'), |
|
180 | - 'default' => $this->organization_config->get_pretty('zip'), |
|
181 | - 'required' => false, |
|
182 | - ) |
|
183 | - ), |
|
184 | - 'organization_email' => new EE_Text_Input( |
|
185 | - array( |
|
186 | - 'html_name' => 'organization_email', |
|
187 | - 'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'), |
|
188 | - 'html_help_text' => sprintf( |
|
189 | - esc_html__( |
|
190 | - 'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.', |
|
191 | - 'event_espresso' |
|
192 | - ), |
|
193 | - '<code>[CO_FORMATTED_EMAIL]</code>', |
|
194 | - '<code>[CO_EMAIL]</code>' |
|
195 | - ), |
|
196 | - 'default' => $this->organization_config->get_pretty('email'), |
|
197 | - 'required' => false, |
|
198 | - ) |
|
199 | - ), |
|
200 | - 'organization_phone' => new EE_Text_Input( |
|
201 | - array( |
|
202 | - 'html_name' => 'organization_phone', |
|
203 | - 'html_label_text' => esc_html__('Phone Number', 'event_espresso'), |
|
204 | - 'html_help_text' => esc_html__( |
|
205 | - 'The phone number for your organization.', |
|
206 | - 'event_espresso' |
|
207 | - ), |
|
208 | - 'default' => $this->organization_config->get_pretty('phone'), |
|
209 | - 'required' => false, |
|
210 | - ) |
|
211 | - ), |
|
212 | - 'organization_vat' => new EE_Text_Input( |
|
213 | - array( |
|
214 | - 'html_name' => 'organization_vat', |
|
215 | - 'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'), |
|
216 | - 'html_help_text' => esc_html__( |
|
217 | - 'The VAT/Tax Number may be displayed on invoices and receipts.', |
|
218 | - 'event_espresso' |
|
219 | - ), |
|
220 | - 'default' => $this->organization_config->get_pretty('vat'), |
|
221 | - 'required' => false, |
|
222 | - ) |
|
223 | - ), |
|
224 | - 'company_logo_hdr' => new EE_Form_Section_HTML( |
|
225 | - EEH_HTML::h2( |
|
226 | - esc_html__('Company Logo', 'event_espresso') |
|
227 | - . ' ' |
|
228 | - . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')), |
|
229 | - '', |
|
230 | - 'company-logo-hdr' |
|
231 | - ) |
|
232 | - ), |
|
233 | - 'organization_logo_url' => new EE_Admin_File_Uploader_Input( |
|
234 | - array( |
|
235 | - 'html_name' => 'organization_logo_url', |
|
236 | - 'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'), |
|
237 | - 'html_help_text' => esc_html__( |
|
238 | - 'Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
239 | - 'event_espresso' |
|
240 | - ), |
|
241 | - 'default' => $this->organization_config->get_pretty('logo_url'), |
|
242 | - 'required' => false, |
|
243 | - ) |
|
244 | - ), |
|
245 | - 'social_links_hdr' => new EE_Form_Section_HTML( |
|
246 | - EEH_HTML::h2( |
|
247 | - esc_html__('Social Links', 'event_espresso') |
|
248 | - . ' ' |
|
249 | - . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info')) |
|
250 | - . EEH_HTML::br() |
|
251 | - . EEH_HTML::p( |
|
252 | - esc_html__( |
|
253 | - 'Enter any links to social accounts for your organization here', |
|
254 | - 'event_espresso' |
|
255 | - ), |
|
256 | - '', |
|
257 | - 'description' |
|
258 | - ), |
|
259 | - '', |
|
260 | - 'social-links-hdr' |
|
261 | - ) |
|
262 | - ), |
|
263 | - 'organization_facebook' => new EE_Text_Input( |
|
264 | - array( |
|
265 | - 'html_name' => 'organization_facebook', |
|
266 | - 'html_label_text' => esc_html__('Facebook', 'event_espresso'), |
|
267 | - 'other_html_attributes' => ' placeholder="facebook.com/profile.name"', |
|
268 | - 'default' => $this->organization_config->get_pretty('facebook'), |
|
269 | - 'required' => false, |
|
270 | - ) |
|
271 | - ), |
|
272 | - 'organization_twitter' => new EE_Text_Input( |
|
273 | - array( |
|
274 | - 'html_name' => 'organization_twitter', |
|
275 | - 'html_label_text' => esc_html__('Twitter', 'event_espresso'), |
|
276 | - 'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"', |
|
277 | - 'default' => $this->organization_config->get_pretty('twitter'), |
|
278 | - 'required' => false, |
|
279 | - ) |
|
280 | - ), |
|
281 | - 'organization_linkedin' => new EE_Text_Input( |
|
282 | - array( |
|
283 | - 'html_name' => 'organization_linkedin', |
|
284 | - 'html_label_text' => esc_html__('LinkedIn', 'event_espresso'), |
|
285 | - 'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"', |
|
286 | - 'default' => $this->organization_config->get_pretty('linkedin'), |
|
287 | - 'required' => false, |
|
288 | - ) |
|
289 | - ), |
|
290 | - 'organization_pinterest' => new EE_Text_Input( |
|
291 | - array( |
|
292 | - 'html_name' => 'organization_pinterest', |
|
293 | - 'html_label_text' => esc_html__('Pinterest', 'event_espresso'), |
|
294 | - 'other_html_attributes' => ' placeholder="pinterest.com/profilename"', |
|
295 | - 'default' => $this->organization_config->get_pretty('pinterest'), |
|
296 | - 'required' => false, |
|
297 | - ) |
|
298 | - ), |
|
299 | - 'organization_google' => new EE_Text_Input( |
|
300 | - array( |
|
301 | - 'html_name' => 'organization_google', |
|
302 | - 'html_label_text' => esc_html__('Google+', 'event_espresso'), |
|
303 | - 'other_html_attributes' => ' placeholder="google.com/+profilename"', |
|
304 | - 'default' => $this->organization_config->get_pretty('google'), |
|
305 | - 'required' => false, |
|
306 | - ) |
|
307 | - ), |
|
308 | - 'organization_instagram' => new EE_Text_Input( |
|
309 | - array( |
|
310 | - 'html_name' => 'organization_instagram', |
|
311 | - 'html_label_text' => esc_html__('Instagram', 'event_espresso'), |
|
312 | - 'other_html_attributes' => ' placeholder="instagram.com/handle"', |
|
313 | - 'default' => $this->organization_config->get_pretty('instagram'), |
|
314 | - 'required' => false, |
|
315 | - ) |
|
316 | - ), |
|
317 | - ), |
|
318 | - ) |
|
319 | - ); |
|
320 | - if (is_main_site()) { |
|
321 | - $form->add_subsections( |
|
322 | - array( |
|
323 | - 'site_license_key_hdr' => new EE_Form_Section_HTML( |
|
324 | - EEH_HTML::h2( |
|
325 | - esc_html__('Your Event Espresso License Key', 'event_espresso') |
|
326 | - . ' ' |
|
327 | - . EEH_HTML::span( |
|
328 | - EEH_Template::get_help_tab_link('site_license_key_info'), |
|
329 | - 'help_tour_activation' |
|
330 | - ), |
|
331 | - '', |
|
332 | - 'site-license-key-hdr' |
|
333 | - ) |
|
334 | - ), |
|
335 | - 'site_license_key' => $this->getSiteLicenseKeyField() |
|
336 | - ) |
|
337 | - ); |
|
338 | - $form->add_subsections( |
|
339 | - array( |
|
340 | - 'uxip_optin_hdr' => new EE_Form_Section_HTML( |
|
341 | - $this->uxipOptinText() |
|
342 | - ), |
|
343 | - 'ueip_optin' => new EE_Checkbox_Multi_Input( |
|
344 | - array( |
|
345 | - true => __('Yes! I want to help improve Event Espresso!', 'event_espresso') |
|
346 | - ), |
|
347 | - array( |
|
348 | - 'html_name' => EE_Core_Config::OPTION_NAME_UXIP, |
|
349 | - 'html_label_text' => esc_html__( |
|
350 | - 'UXIP Opt In?', |
|
351 | - 'event_espresso' |
|
352 | - ), |
|
353 | - 'default' => isset($this->core_config->ee_ueip_optin) |
|
354 | - ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN) |
|
355 | - : false, |
|
356 | - 'required' => false, |
|
357 | - ) |
|
358 | - ), |
|
359 | - ), |
|
360 | - 'organization_instagram', |
|
361 | - false |
|
362 | - ); |
|
363 | - } |
|
364 | - return $form; |
|
365 | - } |
|
91 | + /** |
|
92 | + * creates and returns the actual form |
|
93 | + * |
|
94 | + * @return EE_Form_Section_Proper |
|
95 | + * @throws EE_Error |
|
96 | + */ |
|
97 | + public function generate() |
|
98 | + { |
|
99 | + $form = new EE_Form_Section_Proper( |
|
100 | + array( |
|
101 | + 'name' => 'organization_settings', |
|
102 | + 'html_id' => 'organization_settings', |
|
103 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
104 | + 'subsections' => array( |
|
105 | + 'contact_information_hdr' => new EE_Form_Section_HTML( |
|
106 | + EEH_HTML::h2( |
|
107 | + esc_html__('Contact Information', 'event_espresso') |
|
108 | + . ' ' |
|
109 | + . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')), |
|
110 | + '', |
|
111 | + 'contact-information-hdr' |
|
112 | + ) |
|
113 | + ), |
|
114 | + 'organization_name' => new EE_Text_Input( |
|
115 | + array( |
|
116 | + 'html_name' => 'organization_name', |
|
117 | + 'html_label_text' => esc_html__('Organization Name', 'event_espresso'), |
|
118 | + 'html_help_text' => esc_html__( |
|
119 | + 'Displayed on all emails and invoices.', |
|
120 | + 'event_espresso' |
|
121 | + ), |
|
122 | + 'default' => $this->organization_config->get_pretty('name'), |
|
123 | + 'required' => false, |
|
124 | + ) |
|
125 | + ), |
|
126 | + 'organization_address_1' => new EE_Text_Input( |
|
127 | + array( |
|
128 | + 'html_name' => 'organization_address_1', |
|
129 | + 'html_label_text' => esc_html__('Street Address', 'event_espresso'), |
|
130 | + 'default' => $this->organization_config->get_pretty('address_1'), |
|
131 | + 'required' => false, |
|
132 | + ) |
|
133 | + ), |
|
134 | + 'organization_address_2' => new EE_Text_Input( |
|
135 | + array( |
|
136 | + 'html_name' => 'organization_address_2', |
|
137 | + 'html_label_text' => esc_html__('Street Address 2', 'event_espresso'), |
|
138 | + 'default' => $this->organization_config->get_pretty('address_2'), |
|
139 | + 'required' => false, |
|
140 | + ) |
|
141 | + ), |
|
142 | + 'organization_city' => new EE_Text_Input( |
|
143 | + array( |
|
144 | + 'html_name' => 'organization_city', |
|
145 | + 'html_label_text' => esc_html__('City', 'event_espresso'), |
|
146 | + 'default' => $this->organization_config->get_pretty('city'), |
|
147 | + 'required' => false, |
|
148 | + ) |
|
149 | + ), |
|
150 | + 'organization_state' => new EE_State_Select_Input( |
|
151 | + null, |
|
152 | + array( |
|
153 | + 'html_name' => 'organization_state', |
|
154 | + 'html_label_text' => esc_html__('State/Province', 'event_espresso'), |
|
155 | + 'default' => $this->organization_config->STA_ID, |
|
156 | + 'required' => false, |
|
157 | + ) |
|
158 | + ), |
|
159 | + 'organization_country' => new EE_Country_Select_Input( |
|
160 | + null, |
|
161 | + array( |
|
162 | + 'html_name' => 'organization_country', |
|
163 | + 'html_label_text' => esc_html__('Country', 'event_espresso'), |
|
164 | + 'default' => $this->organization_config->CNT_ISO, |
|
165 | + 'required' => false, |
|
166 | + 'html_help_text' => sprintf( |
|
167 | + esc_html__( |
|
168 | + '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s', |
|
169 | + 'event_espresso' |
|
170 | + ), |
|
171 | + '<span class="reminder-spn">', |
|
172 | + '</span>' |
|
173 | + ), |
|
174 | + ) |
|
175 | + ), |
|
176 | + 'organization_zip' => new EE_Text_Input( |
|
177 | + array( |
|
178 | + 'html_name' => 'organization_zip', |
|
179 | + 'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'), |
|
180 | + 'default' => $this->organization_config->get_pretty('zip'), |
|
181 | + 'required' => false, |
|
182 | + ) |
|
183 | + ), |
|
184 | + 'organization_email' => new EE_Text_Input( |
|
185 | + array( |
|
186 | + 'html_name' => 'organization_email', |
|
187 | + 'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'), |
|
188 | + 'html_help_text' => sprintf( |
|
189 | + esc_html__( |
|
190 | + 'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.', |
|
191 | + 'event_espresso' |
|
192 | + ), |
|
193 | + '<code>[CO_FORMATTED_EMAIL]</code>', |
|
194 | + '<code>[CO_EMAIL]</code>' |
|
195 | + ), |
|
196 | + 'default' => $this->organization_config->get_pretty('email'), |
|
197 | + 'required' => false, |
|
198 | + ) |
|
199 | + ), |
|
200 | + 'organization_phone' => new EE_Text_Input( |
|
201 | + array( |
|
202 | + 'html_name' => 'organization_phone', |
|
203 | + 'html_label_text' => esc_html__('Phone Number', 'event_espresso'), |
|
204 | + 'html_help_text' => esc_html__( |
|
205 | + 'The phone number for your organization.', |
|
206 | + 'event_espresso' |
|
207 | + ), |
|
208 | + 'default' => $this->organization_config->get_pretty('phone'), |
|
209 | + 'required' => false, |
|
210 | + ) |
|
211 | + ), |
|
212 | + 'organization_vat' => new EE_Text_Input( |
|
213 | + array( |
|
214 | + 'html_name' => 'organization_vat', |
|
215 | + 'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'), |
|
216 | + 'html_help_text' => esc_html__( |
|
217 | + 'The VAT/Tax Number may be displayed on invoices and receipts.', |
|
218 | + 'event_espresso' |
|
219 | + ), |
|
220 | + 'default' => $this->organization_config->get_pretty('vat'), |
|
221 | + 'required' => false, |
|
222 | + ) |
|
223 | + ), |
|
224 | + 'company_logo_hdr' => new EE_Form_Section_HTML( |
|
225 | + EEH_HTML::h2( |
|
226 | + esc_html__('Company Logo', 'event_espresso') |
|
227 | + . ' ' |
|
228 | + . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')), |
|
229 | + '', |
|
230 | + 'company-logo-hdr' |
|
231 | + ) |
|
232 | + ), |
|
233 | + 'organization_logo_url' => new EE_Admin_File_Uploader_Input( |
|
234 | + array( |
|
235 | + 'html_name' => 'organization_logo_url', |
|
236 | + 'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'), |
|
237 | + 'html_help_text' => esc_html__( |
|
238 | + 'Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
239 | + 'event_espresso' |
|
240 | + ), |
|
241 | + 'default' => $this->organization_config->get_pretty('logo_url'), |
|
242 | + 'required' => false, |
|
243 | + ) |
|
244 | + ), |
|
245 | + 'social_links_hdr' => new EE_Form_Section_HTML( |
|
246 | + EEH_HTML::h2( |
|
247 | + esc_html__('Social Links', 'event_espresso') |
|
248 | + . ' ' |
|
249 | + . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info')) |
|
250 | + . EEH_HTML::br() |
|
251 | + . EEH_HTML::p( |
|
252 | + esc_html__( |
|
253 | + 'Enter any links to social accounts for your organization here', |
|
254 | + 'event_espresso' |
|
255 | + ), |
|
256 | + '', |
|
257 | + 'description' |
|
258 | + ), |
|
259 | + '', |
|
260 | + 'social-links-hdr' |
|
261 | + ) |
|
262 | + ), |
|
263 | + 'organization_facebook' => new EE_Text_Input( |
|
264 | + array( |
|
265 | + 'html_name' => 'organization_facebook', |
|
266 | + 'html_label_text' => esc_html__('Facebook', 'event_espresso'), |
|
267 | + 'other_html_attributes' => ' placeholder="facebook.com/profile.name"', |
|
268 | + 'default' => $this->organization_config->get_pretty('facebook'), |
|
269 | + 'required' => false, |
|
270 | + ) |
|
271 | + ), |
|
272 | + 'organization_twitter' => new EE_Text_Input( |
|
273 | + array( |
|
274 | + 'html_name' => 'organization_twitter', |
|
275 | + 'html_label_text' => esc_html__('Twitter', 'event_espresso'), |
|
276 | + 'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"', |
|
277 | + 'default' => $this->organization_config->get_pretty('twitter'), |
|
278 | + 'required' => false, |
|
279 | + ) |
|
280 | + ), |
|
281 | + 'organization_linkedin' => new EE_Text_Input( |
|
282 | + array( |
|
283 | + 'html_name' => 'organization_linkedin', |
|
284 | + 'html_label_text' => esc_html__('LinkedIn', 'event_espresso'), |
|
285 | + 'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"', |
|
286 | + 'default' => $this->organization_config->get_pretty('linkedin'), |
|
287 | + 'required' => false, |
|
288 | + ) |
|
289 | + ), |
|
290 | + 'organization_pinterest' => new EE_Text_Input( |
|
291 | + array( |
|
292 | + 'html_name' => 'organization_pinterest', |
|
293 | + 'html_label_text' => esc_html__('Pinterest', 'event_espresso'), |
|
294 | + 'other_html_attributes' => ' placeholder="pinterest.com/profilename"', |
|
295 | + 'default' => $this->organization_config->get_pretty('pinterest'), |
|
296 | + 'required' => false, |
|
297 | + ) |
|
298 | + ), |
|
299 | + 'organization_google' => new EE_Text_Input( |
|
300 | + array( |
|
301 | + 'html_name' => 'organization_google', |
|
302 | + 'html_label_text' => esc_html__('Google+', 'event_espresso'), |
|
303 | + 'other_html_attributes' => ' placeholder="google.com/+profilename"', |
|
304 | + 'default' => $this->organization_config->get_pretty('google'), |
|
305 | + 'required' => false, |
|
306 | + ) |
|
307 | + ), |
|
308 | + 'organization_instagram' => new EE_Text_Input( |
|
309 | + array( |
|
310 | + 'html_name' => 'organization_instagram', |
|
311 | + 'html_label_text' => esc_html__('Instagram', 'event_espresso'), |
|
312 | + 'other_html_attributes' => ' placeholder="instagram.com/handle"', |
|
313 | + 'default' => $this->organization_config->get_pretty('instagram'), |
|
314 | + 'required' => false, |
|
315 | + ) |
|
316 | + ), |
|
317 | + ), |
|
318 | + ) |
|
319 | + ); |
|
320 | + if (is_main_site()) { |
|
321 | + $form->add_subsections( |
|
322 | + array( |
|
323 | + 'site_license_key_hdr' => new EE_Form_Section_HTML( |
|
324 | + EEH_HTML::h2( |
|
325 | + esc_html__('Your Event Espresso License Key', 'event_espresso') |
|
326 | + . ' ' |
|
327 | + . EEH_HTML::span( |
|
328 | + EEH_Template::get_help_tab_link('site_license_key_info'), |
|
329 | + 'help_tour_activation' |
|
330 | + ), |
|
331 | + '', |
|
332 | + 'site-license-key-hdr' |
|
333 | + ) |
|
334 | + ), |
|
335 | + 'site_license_key' => $this->getSiteLicenseKeyField() |
|
336 | + ) |
|
337 | + ); |
|
338 | + $form->add_subsections( |
|
339 | + array( |
|
340 | + 'uxip_optin_hdr' => new EE_Form_Section_HTML( |
|
341 | + $this->uxipOptinText() |
|
342 | + ), |
|
343 | + 'ueip_optin' => new EE_Checkbox_Multi_Input( |
|
344 | + array( |
|
345 | + true => __('Yes! I want to help improve Event Espresso!', 'event_espresso') |
|
346 | + ), |
|
347 | + array( |
|
348 | + 'html_name' => EE_Core_Config::OPTION_NAME_UXIP, |
|
349 | + 'html_label_text' => esc_html__( |
|
350 | + 'UXIP Opt In?', |
|
351 | + 'event_espresso' |
|
352 | + ), |
|
353 | + 'default' => isset($this->core_config->ee_ueip_optin) |
|
354 | + ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN) |
|
355 | + : false, |
|
356 | + 'required' => false, |
|
357 | + ) |
|
358 | + ), |
|
359 | + ), |
|
360 | + 'organization_instagram', |
|
361 | + false |
|
362 | + ); |
|
363 | + } |
|
364 | + return $form; |
|
365 | + } |
|
366 | 366 | |
367 | 367 | |
368 | - /** |
|
369 | - * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
370 | - * returns a string of HTML that can be directly echoed in a template |
|
371 | - * |
|
372 | - * @return string |
|
373 | - * @throws EE_Error |
|
374 | - * @throws InvalidArgumentException |
|
375 | - * @throws InvalidDataTypeException |
|
376 | - * @throws InvalidInterfaceException |
|
377 | - * @throws LogicException |
|
378 | - */ |
|
379 | - public function display() |
|
380 | - { |
|
381 | - $this->form()->enqueue_js(); |
|
382 | - return parent::display(); |
|
383 | - } |
|
368 | + /** |
|
369 | + * takes the generated form and displays it along with ony other non-form HTML that may be required |
|
370 | + * returns a string of HTML that can be directly echoed in a template |
|
371 | + * |
|
372 | + * @return string |
|
373 | + * @throws EE_Error |
|
374 | + * @throws InvalidArgumentException |
|
375 | + * @throws InvalidDataTypeException |
|
376 | + * @throws InvalidInterfaceException |
|
377 | + * @throws LogicException |
|
378 | + */ |
|
379 | + public function display() |
|
380 | + { |
|
381 | + $this->form()->enqueue_js(); |
|
382 | + return parent::display(); |
|
383 | + } |
|
384 | 384 | |
385 | 385 | |
386 | - /** |
|
387 | - * handles processing the form submission |
|
388 | - * returns true or false depending on whether the form was processed successfully or not |
|
389 | - * |
|
390 | - * @param array $form_data |
|
391 | - * @return bool |
|
392 | - * @throws InvalidFormSubmissionException |
|
393 | - * @throws EE_Error |
|
394 | - * @throws LogicException |
|
395 | - * @throws InvalidArgumentException |
|
396 | - * @throws InvalidDataTypeException |
|
397 | - */ |
|
398 | - public function process($form_data = array()) |
|
399 | - { |
|
400 | - // process form |
|
401 | - $valid_data = (array) parent::process($form_data); |
|
402 | - if (empty($valid_data)) { |
|
403 | - return false; |
|
404 | - } |
|
386 | + /** |
|
387 | + * handles processing the form submission |
|
388 | + * returns true or false depending on whether the form was processed successfully or not |
|
389 | + * |
|
390 | + * @param array $form_data |
|
391 | + * @return bool |
|
392 | + * @throws InvalidFormSubmissionException |
|
393 | + * @throws EE_Error |
|
394 | + * @throws LogicException |
|
395 | + * @throws InvalidArgumentException |
|
396 | + * @throws InvalidDataTypeException |
|
397 | + */ |
|
398 | + public function process($form_data = array()) |
|
399 | + { |
|
400 | + // process form |
|
401 | + $valid_data = (array) parent::process($form_data); |
|
402 | + if (empty($valid_data)) { |
|
403 | + return false; |
|
404 | + } |
|
405 | 405 | |
406 | - if (is_main_site()) { |
|
407 | - $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key']) |
|
408 | - ? sanitize_text_field($form_data['ee_site_license_key']) |
|
409 | - : $this->network_core_config->site_license_key; |
|
410 | - } |
|
411 | - $this->organization_config->name = isset($form_data['organization_name']) |
|
412 | - ? sanitize_text_field($form_data['organization_name']) |
|
413 | - : $this->organization_config->name; |
|
414 | - $this->organization_config->address_1 = isset($form_data['organization_address_1']) |
|
415 | - ? sanitize_text_field($form_data['organization_address_1']) |
|
416 | - : $this->organization_config->address_1; |
|
417 | - $this->organization_config->address_2 = isset($form_data['organization_address_2']) |
|
418 | - ? sanitize_text_field($form_data['organization_address_2']) |
|
419 | - : $this->organization_config->address_2; |
|
420 | - $this->organization_config->city = isset($form_data['organization_city']) |
|
421 | - ? sanitize_text_field($form_data['organization_city']) |
|
422 | - : $this->organization_config->city; |
|
423 | - $this->organization_config->STA_ID = isset($form_data['organization_state']) |
|
424 | - ? absint($form_data['organization_state']) |
|
425 | - : $this->organization_config->STA_ID; |
|
426 | - $this->organization_config->CNT_ISO = isset($form_data['organization_country']) |
|
427 | - ? sanitize_text_field($form_data['organization_country']) |
|
428 | - : $this->organization_config->CNT_ISO; |
|
429 | - $this->organization_config->zip = isset($form_data['organization_zip']) |
|
430 | - ? sanitize_text_field($form_data['organization_zip']) |
|
431 | - : $this->organization_config->zip; |
|
432 | - $this->organization_config->email = isset($form_data['organization_email']) |
|
433 | - ? sanitize_email($form_data['organization_email']) |
|
434 | - : $this->organization_config->email; |
|
435 | - $this->organization_config->vat = isset($form_data['organization_vat']) |
|
436 | - ? sanitize_text_field($form_data['organization_vat']) |
|
437 | - : $this->organization_config->vat; |
|
438 | - $this->organization_config->phone = isset($form_data['organization_phone']) |
|
439 | - ? sanitize_text_field($form_data['organization_phone']) |
|
440 | - : $this->organization_config->phone; |
|
441 | - $this->organization_config->logo_url = isset($form_data['organization_logo_url']) |
|
442 | - ? esc_url_raw($form_data['organization_logo_url']) |
|
443 | - : $this->organization_config->logo_url; |
|
444 | - $this->organization_config->facebook = isset($form_data['organization_facebook']) |
|
445 | - ? esc_url_raw($form_data['organization_facebook']) |
|
446 | - : $this->organization_config->facebook; |
|
447 | - $this->organization_config->twitter = isset($form_data['organization_twitter']) |
|
448 | - ? esc_url_raw($form_data['organization_twitter']) |
|
449 | - : $this->organization_config->twitter; |
|
450 | - $this->organization_config->linkedin = isset($form_data['organization_linkedin']) |
|
451 | - ? esc_url_raw($form_data['organization_linkedin']) |
|
452 | - : $this->organization_config->linkedin; |
|
453 | - $this->organization_config->pinterest = isset($form_data['organization_pinterest']) |
|
454 | - ? esc_url_raw($form_data['organization_pinterest']) |
|
455 | - : $this->organization_config->pinterest; |
|
456 | - $this->organization_config->google = isset($form_data['organization_google']) |
|
457 | - ? esc_url_raw($form_data['organization_google']) |
|
458 | - : $this->organization_config->google; |
|
459 | - $this->organization_config->instagram = isset($form_data['organization_instagram']) |
|
460 | - ? esc_url_raw($form_data['organization_instagram']) |
|
461 | - : $this->organization_config->instagram; |
|
462 | - $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0]) |
|
463 | - ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN) |
|
464 | - : false; |
|
465 | - $this->core_config->ee_ueip_has_notified = true; |
|
406 | + if (is_main_site()) { |
|
407 | + $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key']) |
|
408 | + ? sanitize_text_field($form_data['ee_site_license_key']) |
|
409 | + : $this->network_core_config->site_license_key; |
|
410 | + } |
|
411 | + $this->organization_config->name = isset($form_data['organization_name']) |
|
412 | + ? sanitize_text_field($form_data['organization_name']) |
|
413 | + : $this->organization_config->name; |
|
414 | + $this->organization_config->address_1 = isset($form_data['organization_address_1']) |
|
415 | + ? sanitize_text_field($form_data['organization_address_1']) |
|
416 | + : $this->organization_config->address_1; |
|
417 | + $this->organization_config->address_2 = isset($form_data['organization_address_2']) |
|
418 | + ? sanitize_text_field($form_data['organization_address_2']) |
|
419 | + : $this->organization_config->address_2; |
|
420 | + $this->organization_config->city = isset($form_data['organization_city']) |
|
421 | + ? sanitize_text_field($form_data['organization_city']) |
|
422 | + : $this->organization_config->city; |
|
423 | + $this->organization_config->STA_ID = isset($form_data['organization_state']) |
|
424 | + ? absint($form_data['organization_state']) |
|
425 | + : $this->organization_config->STA_ID; |
|
426 | + $this->organization_config->CNT_ISO = isset($form_data['organization_country']) |
|
427 | + ? sanitize_text_field($form_data['organization_country']) |
|
428 | + : $this->organization_config->CNT_ISO; |
|
429 | + $this->organization_config->zip = isset($form_data['organization_zip']) |
|
430 | + ? sanitize_text_field($form_data['organization_zip']) |
|
431 | + : $this->organization_config->zip; |
|
432 | + $this->organization_config->email = isset($form_data['organization_email']) |
|
433 | + ? sanitize_email($form_data['organization_email']) |
|
434 | + : $this->organization_config->email; |
|
435 | + $this->organization_config->vat = isset($form_data['organization_vat']) |
|
436 | + ? sanitize_text_field($form_data['organization_vat']) |
|
437 | + : $this->organization_config->vat; |
|
438 | + $this->organization_config->phone = isset($form_data['organization_phone']) |
|
439 | + ? sanitize_text_field($form_data['organization_phone']) |
|
440 | + : $this->organization_config->phone; |
|
441 | + $this->organization_config->logo_url = isset($form_data['organization_logo_url']) |
|
442 | + ? esc_url_raw($form_data['organization_logo_url']) |
|
443 | + : $this->organization_config->logo_url; |
|
444 | + $this->organization_config->facebook = isset($form_data['organization_facebook']) |
|
445 | + ? esc_url_raw($form_data['organization_facebook']) |
|
446 | + : $this->organization_config->facebook; |
|
447 | + $this->organization_config->twitter = isset($form_data['organization_twitter']) |
|
448 | + ? esc_url_raw($form_data['organization_twitter']) |
|
449 | + : $this->organization_config->twitter; |
|
450 | + $this->organization_config->linkedin = isset($form_data['organization_linkedin']) |
|
451 | + ? esc_url_raw($form_data['organization_linkedin']) |
|
452 | + : $this->organization_config->linkedin; |
|
453 | + $this->organization_config->pinterest = isset($form_data['organization_pinterest']) |
|
454 | + ? esc_url_raw($form_data['organization_pinterest']) |
|
455 | + : $this->organization_config->pinterest; |
|
456 | + $this->organization_config->google = isset($form_data['organization_google']) |
|
457 | + ? esc_url_raw($form_data['organization_google']) |
|
458 | + : $this->organization_config->google; |
|
459 | + $this->organization_config->instagram = isset($form_data['organization_instagram']) |
|
460 | + ? esc_url_raw($form_data['organization_instagram']) |
|
461 | + : $this->organization_config->instagram; |
|
462 | + $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0]) |
|
463 | + ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN) |
|
464 | + : false; |
|
465 | + $this->core_config->ee_ueip_has_notified = true; |
|
466 | 466 | |
467 | - $this->registry->CFG->currency = new EE_Currency_Config( |
|
468 | - $this->organization_config->CNT_ISO |
|
469 | - ); |
|
470 | - return true; |
|
471 | - } |
|
467 | + $this->registry->CFG->currency = new EE_Currency_Config( |
|
468 | + $this->organization_config->CNT_ISO |
|
469 | + ); |
|
470 | + return true; |
|
471 | + } |
|
472 | 472 | |
473 | 473 | |
474 | - /** |
|
475 | - * @return string |
|
476 | - */ |
|
477 | - private function uxipOptinText() |
|
478 | - { |
|
479 | - ob_start(); |
|
480 | - Stats::optinText(false); |
|
481 | - return ob_get_clean(); |
|
482 | - } |
|
474 | + /** |
|
475 | + * @return string |
|
476 | + */ |
|
477 | + private function uxipOptinText() |
|
478 | + { |
|
479 | + ob_start(); |
|
480 | + Stats::optinText(false); |
|
481 | + return ob_get_clean(); |
|
482 | + } |
|
483 | 483 | |
484 | 484 | |
485 | - /** |
|
486 | - * Return whether the site license key has been verified or not. |
|
487 | - * @return bool |
|
488 | - */ |
|
489 | - private function licenseKeyVerified() |
|
490 | - { |
|
491 | - if (empty($this->network_core_config->site_license_key)) { |
|
492 | - return false; |
|
493 | - } |
|
494 | - $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
495 | - $verify_fail = get_option($ver_option_key, false); |
|
496 | - return $verify_fail === false |
|
497 | - || (! empty($this->network_core_config->site_license_key) |
|
498 | - && $verify_fail === false |
|
499 | - ); |
|
500 | - } |
|
485 | + /** |
|
486 | + * Return whether the site license key has been verified or not. |
|
487 | + * @return bool |
|
488 | + */ |
|
489 | + private function licenseKeyVerified() |
|
490 | + { |
|
491 | + if (empty($this->network_core_config->site_license_key)) { |
|
492 | + return false; |
|
493 | + } |
|
494 | + $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME); |
|
495 | + $verify_fail = get_option($ver_option_key, false); |
|
496 | + return $verify_fail === false |
|
497 | + || (! empty($this->network_core_config->site_license_key) |
|
498 | + && $verify_fail === false |
|
499 | + ); |
|
500 | + } |
|
501 | 501 | |
502 | 502 | |
503 | - /** |
|
504 | - * @return EE_Text_Input |
|
505 | - */ |
|
506 | - private function getSiteLicenseKeyField() |
|
507 | - { |
|
508 | - $text_input = new EE_Text_Input( |
|
509 | - array( |
|
510 | - 'html_name' => 'ee_site_license_key', |
|
511 | - 'html_id' => 'site_license_key', |
|
512 | - 'html_label_text' => esc_html__('Support License Key', 'event_espresso'), |
|
513 | - /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */ |
|
514 | - 'html_help_text' => sprintf( |
|
515 | - esc_html__( |
|
516 | - 'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.', |
|
517 | - 'event_espresso' |
|
518 | - ), |
|
519 | - '<strong>', |
|
520 | - '</strong>' |
|
521 | - ), |
|
522 | - /** phpcs:enable */ |
|
523 | - 'default' => isset($this->network_core_config->site_license_key) |
|
524 | - ? $this->network_core_config->site_license_key |
|
525 | - : '', |
|
526 | - 'required' => false, |
|
527 | - 'form_html_filter' => new VsprintfFilter( |
|
528 | - '%2$s %1$s', |
|
529 | - array($this->getValidationIndicator()) |
|
530 | - ) |
|
531 | - ) |
|
532 | - ); |
|
533 | - return $text_input; |
|
534 | - } |
|
503 | + /** |
|
504 | + * @return EE_Text_Input |
|
505 | + */ |
|
506 | + private function getSiteLicenseKeyField() |
|
507 | + { |
|
508 | + $text_input = new EE_Text_Input( |
|
509 | + array( |
|
510 | + 'html_name' => 'ee_site_license_key', |
|
511 | + 'html_id' => 'site_license_key', |
|
512 | + 'html_label_text' => esc_html__('Support License Key', 'event_espresso'), |
|
513 | + /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */ |
|
514 | + 'html_help_text' => sprintf( |
|
515 | + esc_html__( |
|
516 | + 'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.', |
|
517 | + 'event_espresso' |
|
518 | + ), |
|
519 | + '<strong>', |
|
520 | + '</strong>' |
|
521 | + ), |
|
522 | + /** phpcs:enable */ |
|
523 | + 'default' => isset($this->network_core_config->site_license_key) |
|
524 | + ? $this->network_core_config->site_license_key |
|
525 | + : '', |
|
526 | + 'required' => false, |
|
527 | + 'form_html_filter' => new VsprintfFilter( |
|
528 | + '%2$s %1$s', |
|
529 | + array($this->getValidationIndicator()) |
|
530 | + ) |
|
531 | + ) |
|
532 | + ); |
|
533 | + return $text_input; |
|
534 | + } |
|
535 | 535 | |
536 | 536 | |
537 | - /** |
|
538 | - * @return string |
|
539 | - */ |
|
540 | - private function getValidationIndicator() |
|
541 | - { |
|
542 | - $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red'; |
|
543 | - return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>'; |
|
544 | - } |
|
537 | + /** |
|
538 | + * @return string |
|
539 | + */ |
|
540 | + private function getValidationIndicator() |
|
541 | + { |
|
542 | + $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red'; |
|
543 | + return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>'; |
|
544 | + } |
|
545 | 545 | } |
@@ -289,12 +289,12 @@ discard block |
||
289 | 289 | wp_enqueue_script('thickbox'); |
290 | 290 | wp_register_script( |
291 | 291 | 'organization_settings', |
292 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
292 | + GEN_SET_ASSETS_URL.'your_organization_settings.js', |
|
293 | 293 | array('jquery', 'media-upload', 'thickbox'), |
294 | 294 | EVENT_ESPRESSO_VERSION, |
295 | 295 | true |
296 | 296 | ); |
297 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
297 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
298 | 298 | wp_enqueue_script('organization_settings'); |
299 | 299 | wp_enqueue_style('organization-css'); |
300 | 300 | $confirm_image_delete = array( |
@@ -315,12 +315,12 @@ discard block |
||
315 | 315 | // scripts |
316 | 316 | wp_register_script( |
317 | 317 | 'gen_settings_countries', |
318 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
318 | + GEN_SET_ASSETS_URL.'gen_settings_countries.js', |
|
319 | 319 | array('ee_admin_js'), |
320 | 320 | EVENT_ESPRESSO_VERSION, |
321 | 321 | true |
322 | 322 | ); |
323 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
323 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
324 | 324 | wp_enqueue_script('gen_settings_countries'); |
325 | 325 | wp_enqueue_style('organization-css'); |
326 | 326 | } |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
371 | 371 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
372 | 372 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
373 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
373 | + GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php', |
|
374 | 374 | $this->_template_args, |
375 | 375 | true |
376 | 376 | ); |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | { |
535 | 535 | try { |
536 | 536 | $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
537 | - $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
537 | + $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]); |
|
538 | 538 | EE_Registry::instance()->CFG->admin = apply_filters( |
539 | 539 | 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
540 | 540 | EE_Registry::instance()->CFG->admin |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | $this->_set_add_edit_form_tags('update_country_settings'); |
613 | 613 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
614 | 614 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
615 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
615 | + GEN_SET_TEMPLATE_PATH.'countries_settings.template.php', |
|
616 | 616 | $this->_template_args, |
617 | 617 | true |
618 | 618 | ); |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | $CNT_ISO = isset($this->_req_data['country']) |
638 | 638 | ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
639 | 639 | : $CNT_ISO; |
640 | - if (! $CNT_ISO) { |
|
640 | + if ( ! $CNT_ISO) { |
|
641 | 641 | return ''; |
642 | 642 | } |
643 | 643 | |
@@ -656,59 +656,59 @@ discard block |
||
656 | 656 | $country_input_types = array( |
657 | 657 | 'CNT_active' => array( |
658 | 658 | 'type' => 'RADIO_BTN', |
659 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
659 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
660 | 660 | 'class' => '', |
661 | 661 | 'options' => $this->_yes_no_values, |
662 | 662 | 'use_desc_4_label' => true, |
663 | 663 | ), |
664 | 664 | 'CNT_ISO' => array( |
665 | 665 | 'type' => 'TEXT', |
666 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
666 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
667 | 667 | 'class' => 'small-text', |
668 | 668 | ), |
669 | 669 | 'CNT_ISO3' => array( |
670 | 670 | 'type' => 'TEXT', |
671 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
671 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
672 | 672 | 'class' => 'small-text', |
673 | 673 | ), |
674 | 674 | 'RGN_ID' => array( |
675 | 675 | 'type' => 'TEXT', |
676 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
676 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
677 | 677 | 'class' => 'small-text', |
678 | 678 | ), |
679 | 679 | 'CNT_name' => array( |
680 | 680 | 'type' => 'TEXT', |
681 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
681 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
682 | 682 | 'class' => 'regular-text', |
683 | 683 | ), |
684 | 684 | 'CNT_cur_code' => array( |
685 | 685 | 'type' => 'TEXT', |
686 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
686 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
687 | 687 | 'class' => 'small-text', |
688 | 688 | 'disabled' => $CNT_cur_disabled |
689 | 689 | ), |
690 | 690 | 'CNT_cur_single' => array( |
691 | 691 | 'type' => 'TEXT', |
692 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
692 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
693 | 693 | 'class' => 'medium-text', |
694 | 694 | 'disabled' => $CNT_cur_disabled |
695 | 695 | ), |
696 | 696 | 'CNT_cur_plural' => array( |
697 | 697 | 'type' => 'TEXT', |
698 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
698 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
699 | 699 | 'class' => 'medium-text', |
700 | 700 | 'disabled' => $CNT_cur_disabled |
701 | 701 | ), |
702 | 702 | 'CNT_cur_sign' => array( |
703 | 703 | 'type' => 'TEXT', |
704 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
704 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
705 | 705 | 'class' => 'small-text', |
706 | 706 | 'htmlentities' => false, |
707 | 707 | 'disabled' => $CNT_cur_disabled |
708 | 708 | ), |
709 | 709 | 'CNT_cur_sign_b4' => array( |
710 | 710 | 'type' => 'RADIO_BTN', |
711 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
711 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
712 | 712 | 'class' => '', |
713 | 713 | 'options' => $this->_yes_no_values, |
714 | 714 | 'use_desc_4_label' => true, |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | ), |
717 | 717 | 'CNT_cur_dec_plc' => array( |
718 | 718 | 'type' => 'RADIO_BTN', |
719 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
719 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
720 | 720 | 'class' => '', |
721 | 721 | 'options' => array( |
722 | 722 | array('id' => 0, 'text' => ''), |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | ), |
729 | 729 | 'CNT_cur_dec_mrk' => array( |
730 | 730 | 'type' => 'RADIO_BTN', |
731 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
731 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
732 | 732 | 'class' => '', |
733 | 733 | 'options' => array( |
734 | 734 | array( |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | ), |
743 | 743 | 'CNT_cur_thsnds' => array( |
744 | 744 | 'type' => 'RADIO_BTN', |
745 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
745 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
746 | 746 | 'class' => '', |
747 | 747 | 'options' => array( |
748 | 748 | array( |
@@ -756,12 +756,12 @@ discard block |
||
756 | 756 | ), |
757 | 757 | 'CNT_tel_code' => array( |
758 | 758 | 'type' => 'TEXT', |
759 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
759 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
760 | 760 | 'class' => 'small-text', |
761 | 761 | ), |
762 | 762 | 'CNT_is_EU' => array( |
763 | 763 | 'type' => 'RADIO_BTN', |
764 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
764 | + 'input_name' => 'cntry['.$CNT_ISO.']', |
|
765 | 765 | 'class' => '', |
766 | 766 | 'options' => $this->_yes_no_values, |
767 | 767 | 'use_desc_4_label' => true, |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | $country_input_types |
773 | 773 | ); |
774 | 774 | $country_details_settings = EEH_Template::display_template( |
775 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
775 | + GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php', |
|
776 | 776 | $this->_template_args, |
777 | 777 | true |
778 | 778 | ); |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | |
807 | 807 | $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
808 | 808 | |
809 | - if (! $CNT_ISO) { |
|
809 | + if ( ! $CNT_ISO) { |
|
810 | 810 | return ''; |
811 | 811 | } |
812 | 812 | // for ajax |
@@ -823,22 +823,22 @@ discard block |
||
823 | 823 | $state_input_types = array( |
824 | 824 | 'STA_abbrev' => array( |
825 | 825 | 'type' => 'TEXT', |
826 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
826 | + 'input_name' => 'states['.$STA_ID.']', |
|
827 | 827 | 'class' => 'mid-text', |
828 | 828 | ), |
829 | 829 | 'STA_name' => array( |
830 | 830 | 'type' => 'TEXT', |
831 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
831 | + 'input_name' => 'states['.$STA_ID.']', |
|
832 | 832 | 'class' => 'regular-text', |
833 | 833 | ), |
834 | 834 | 'STA_active' => array( |
835 | 835 | 'type' => 'RADIO_BTN', |
836 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
836 | + 'input_name' => 'states['.$STA_ID.']', |
|
837 | 837 | 'options' => $this->_yes_no_values, |
838 | 838 | 'use_desc_4_label' => true, |
839 | 839 | ), |
840 | 840 | ); |
841 | - $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
841 | + $this->_template_args['states'][$STA_ID]['inputs'] = |
|
842 | 842 | EE_Question_Form_Input::generate_question_form_inputs_for_object( |
843 | 843 | $state, |
844 | 844 | $state_input_types |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | 'CNT_ISO' => $CNT_ISO, |
850 | 850 | 'STA_abbrev' => $state->abbrev(), |
851 | 851 | ); |
852 | - $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
852 | + $this->_template_args['states'][$STA_ID]['delete_state_url'] = |
|
853 | 853 | EE_Admin_Page::add_query_args_and_nonce( |
854 | 854 | $query_args, |
855 | 855 | GEN_SET_ADMIN_URL |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | ); |
867 | 867 | |
868 | 868 | $state_details_settings = EEH_Template::display_template( |
869 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
869 | + GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php', |
|
870 | 870 | $this->_template_args, |
871 | 871 | true |
872 | 872 | ); |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
903 | 903 | ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
904 | 904 | : false; |
905 | - if (! $CNT_ISO) { |
|
905 | + if ( ! $CNT_ISO) { |
|
906 | 906 | EE_Error::add_error( |
907 | 907 | __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
908 | 908 | __FILE__, |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
915 | 915 | ? sanitize_text_field($this->_req_data['STA_abbrev']) |
916 | 916 | : false; |
917 | - if (! $STA_abbrev) { |
|
917 | + if ( ! $STA_abbrev) { |
|
918 | 918 | EE_Error::add_error( |
919 | 919 | __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
920 | 920 | __FILE__, |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | $STA_name = isset($this->_req_data['STA_name']) |
927 | 927 | ? sanitize_text_field($this->_req_data['STA_name']) |
928 | 928 | : false; |
929 | - if (! $STA_name) { |
|
929 | + if ( ! $STA_name) { |
|
930 | 930 | EE_Error::add_error( |
931 | 931 | __('No State name or an invalid State name was received.', 'event_espresso'), |
932 | 932 | __FILE__, |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
977 | 977 | ? sanitize_text_field($this->_req_data['STA_abbrev']) |
978 | 978 | : false; |
979 | - if (! $STA_ID) { |
|
979 | + if ( ! $STA_ID) { |
|
980 | 980 | EE_Error::add_error( |
981 | 981 | __('No State ID or an invalid State ID was received.', 'event_espresso'), |
982 | 982 | __FILE__, |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | $CNT_ISO = isset($this->_req_data['country']) |
1026 | 1026 | ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
1027 | 1027 | : false; |
1028 | - if (! $CNT_ISO) { |
|
1028 | + if ( ! $CNT_ISO) { |
|
1029 | 1029 | EE_Error::add_error( |
1030 | 1030 | __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
1031 | 1031 | __FILE__, |
@@ -1036,47 +1036,47 @@ discard block |
||
1036 | 1036 | return; |
1037 | 1037 | } |
1038 | 1038 | $cols_n_values = array(); |
1039 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
1040 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
1039 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) |
|
1040 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) |
|
1041 | 1041 | : false; |
1042 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1043 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1042 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
1043 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) |
|
1044 | 1044 | : null; |
1045 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1046 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1045 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
1046 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) |
|
1047 | 1047 | : null; |
1048 | - $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1049 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) |
|
1048 | + $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) |
|
1049 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) |
|
1050 | 1050 | : 'USD'; |
1051 | - $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1052 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1051 | + $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
1052 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) |
|
1053 | 1053 | : 'dollar'; |
1054 | - $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1055 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1054 | + $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
1055 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) |
|
1056 | 1056 | : 'dollars'; |
1057 | - $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1058 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1057 | + $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
1058 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) |
|
1059 | 1059 | : '$'; |
1060 | - $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1061 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1060 | + $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
1061 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) |
|
1062 | 1062 | : true; |
1063 | - $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1064 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1063 | + $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
1064 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) |
|
1065 | 1065 | : 2; |
1066 | - $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1067 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1066 | + $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
1067 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) |
|
1068 | 1068 | : '.'; |
1069 | - $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1070 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1069 | + $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
1070 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) |
|
1071 | 1071 | : ','; |
1072 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1073 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1072 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
1073 | + ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) |
|
1074 | 1074 | : null; |
1075 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1076 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1075 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
1076 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) |
|
1077 | 1077 | : false; |
1078 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1079 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1078 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
1079 | + ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) |
|
1080 | 1080 | : false; |
1081 | 1081 | // allow filtering of country data |
1082 | 1082 | $cols_n_values = apply_filters( |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | return ' |
1154 | 1154 | <tr> |
1155 | 1155 | <th> |
1156 | - ' . $label . ' |
|
1156 | + ' . $label.' |
|
1157 | 1157 | </th>'; |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | { |
1170 | 1170 | return ' |
1171 | 1171 | <td class="general-settings-country-input-td"> |
1172 | - ' . $input . ' |
|
1172 | + ' . $input.' |
|
1173 | 1173 | </td> |
1174 | 1174 | </tr>'; |
1175 | 1175 | } |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | { |
1201 | 1201 | return ' |
1202 | 1202 | <td class="general-settings-country-state-input-td"> |
1203 | - ' . $input . ' |
|
1203 | + ' . $input.' |
|
1204 | 1204 | </td>'; |
1205 | 1205 | } |
1206 | 1206 | |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | . __('Edit', 'event_espresso') |
1227 | 1227 | . '</a>'; |
1228 | 1228 | $links .= ' | '; |
1229 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1229 | + $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>'; |
|
1230 | 1230 | |
1231 | 1231 | return $links; |
1232 | 1232 | } |
@@ -1259,9 +1259,9 @@ discard block |
||
1259 | 1259 | $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
1260 | 1260 | } |
1261 | 1261 | |
1262 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1262 | + return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>' |
|
1263 | 1263 | . $pg_status |
1264 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1264 | + . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>'; |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 |
@@ -21,1323 +21,1323 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * _question_group |
|
26 | - * holds the specific question group object for the question group details screen |
|
27 | - * |
|
28 | - * @var object |
|
29 | - */ |
|
30 | - protected $_question_group; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Initialize basic properties. |
|
35 | - */ |
|
36 | - protected function _init_page_props() |
|
37 | - { |
|
38 | - $this->page_slug = GEN_SET_PG_SLUG; |
|
39 | - $this->page_label = GEN_SET_LABEL; |
|
40 | - $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
41 | - $this->_admin_base_path = GEN_SET_ADMIN; |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Set ajax hooks |
|
47 | - */ |
|
48 | - protected function _ajax_hooks() |
|
49 | - { |
|
50 | - add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
51 | - add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
52 | - add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
53 | - add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * More page properties initialization. |
|
59 | - */ |
|
60 | - protected function _define_page_props() |
|
61 | - { |
|
62 | - $this->_admin_page_title = GEN_SET_LABEL; |
|
63 | - $this->_labels = array( |
|
64 | - 'publishbox' => __('Update Settings', 'event_espresso'), |
|
65 | - ); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Set page routes property. |
|
71 | - */ |
|
72 | - protected function _set_page_routes() |
|
73 | - { |
|
74 | - $this->_page_routes = array( |
|
75 | - |
|
76 | - 'critical_pages' => array( |
|
77 | - 'func' => '_espresso_page_settings', |
|
78 | - 'capability' => 'manage_options', |
|
79 | - ), |
|
80 | - 'update_espresso_page_settings' => array( |
|
81 | - 'func' => '_update_espresso_page_settings', |
|
82 | - 'capability' => 'manage_options', |
|
83 | - 'noheader' => true, |
|
84 | - ), |
|
85 | - 'default' => array( |
|
86 | - 'func' => '_your_organization_settings', |
|
87 | - 'capability' => 'manage_options', |
|
88 | - ), |
|
89 | - |
|
90 | - 'update_your_organization_settings' => array( |
|
91 | - 'func' => '_update_your_organization_settings', |
|
92 | - 'capability' => 'manage_options', |
|
93 | - 'noheader' => true, |
|
94 | - ), |
|
95 | - |
|
96 | - 'admin_option_settings' => array( |
|
97 | - 'func' => '_admin_option_settings', |
|
98 | - 'capability' => 'manage_options', |
|
99 | - ), |
|
100 | - |
|
101 | - 'update_admin_option_settings' => array( |
|
102 | - 'func' => '_update_admin_option_settings', |
|
103 | - 'capability' => 'manage_options', |
|
104 | - 'noheader' => true, |
|
105 | - ), |
|
106 | - |
|
107 | - 'country_settings' => array( |
|
108 | - 'func' => '_country_settings', |
|
109 | - 'capability' => 'manage_options', |
|
110 | - ), |
|
111 | - |
|
112 | - 'update_country_settings' => array( |
|
113 | - 'func' => '_update_country_settings', |
|
114 | - 'capability' => 'manage_options', |
|
115 | - 'noheader' => true, |
|
116 | - ), |
|
117 | - |
|
118 | - 'display_country_settings' => array( |
|
119 | - 'func' => 'display_country_settings', |
|
120 | - 'capability' => 'manage_options', |
|
121 | - 'noheader' => true, |
|
122 | - ), |
|
123 | - |
|
124 | - 'add_new_state' => array( |
|
125 | - 'func' => 'add_new_state', |
|
126 | - 'capability' => 'manage_options', |
|
127 | - 'noheader' => true, |
|
128 | - ), |
|
129 | - |
|
130 | - 'delete_state' => array( |
|
131 | - 'func' => 'delete_state', |
|
132 | - 'capability' => 'manage_options', |
|
133 | - 'noheader' => true, |
|
134 | - ), |
|
135 | - 'privacy_settings' => array( |
|
136 | - 'func' => 'privacySettings', |
|
137 | - 'capability' => 'manage_options', |
|
138 | - ), |
|
139 | - 'update_privacy_settings' => array( |
|
140 | - 'func' => 'updatePrivacySettings', |
|
141 | - 'capability' => 'manage_options', |
|
142 | - 'noheader' => true, |
|
143 | - 'headers_sent_route' => 'privacy_settings' |
|
144 | - ) |
|
145 | - ); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * Set page configuration property |
|
151 | - */ |
|
152 | - protected function _set_page_config() |
|
153 | - { |
|
154 | - $this->_page_config = array( |
|
155 | - 'critical_pages' => array( |
|
156 | - 'nav' => array( |
|
157 | - 'label' => __('Critical Pages', 'event_espresso'), |
|
158 | - 'order' => 50, |
|
159 | - ), |
|
160 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
161 | - 'help_tabs' => array( |
|
162 | - 'general_settings_critical_pages_help_tab' => array( |
|
163 | - 'title' => __('Critical Pages', 'event_espresso'), |
|
164 | - 'filename' => 'general_settings_critical_pages', |
|
165 | - ), |
|
166 | - ), |
|
167 | - 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
168 | - 'require_nonce' => false, |
|
169 | - ), |
|
170 | - 'default' => array( |
|
171 | - 'nav' => array( |
|
172 | - 'label' => __('Your Organization', 'event_espresso'), |
|
173 | - 'order' => 20, |
|
174 | - ), |
|
175 | - 'help_tabs' => array( |
|
176 | - 'general_settings_your_organization_help_tab' => array( |
|
177 | - 'title' => __('Your Organization', 'event_espresso'), |
|
178 | - 'filename' => 'general_settings_your_organization', |
|
179 | - ), |
|
180 | - ), |
|
181 | - 'help_tour' => array('Your_Organization_Help_Tour'), |
|
182 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
183 | - 'require_nonce' => false, |
|
184 | - ), |
|
185 | - 'admin_option_settings' => array( |
|
186 | - 'nav' => array( |
|
187 | - 'label' => __('Admin Options', 'event_espresso'), |
|
188 | - 'order' => 60, |
|
189 | - ), |
|
190 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
191 | - 'help_tabs' => array( |
|
192 | - 'general_settings_admin_options_help_tab' => array( |
|
193 | - 'title' => __('Admin Options', 'event_espresso'), |
|
194 | - 'filename' => 'general_settings_admin_options', |
|
195 | - ), |
|
196 | - ), |
|
197 | - 'help_tour' => array('Admin_Options_Help_Tour'), |
|
198 | - 'require_nonce' => false, |
|
199 | - ), |
|
200 | - 'country_settings' => array( |
|
201 | - 'nav' => array( |
|
202 | - 'label' => __('Countries', 'event_espresso'), |
|
203 | - 'order' => 70, |
|
204 | - ), |
|
205 | - 'help_tabs' => array( |
|
206 | - 'general_settings_countries_help_tab' => array( |
|
207 | - 'title' => __('Countries', 'event_espresso'), |
|
208 | - 'filename' => 'general_settings_countries', |
|
209 | - ), |
|
210 | - ), |
|
211 | - 'help_tour' => array('Countries_Help_Tour'), |
|
212 | - 'require_nonce' => false, |
|
213 | - ), |
|
214 | - 'privacy_settings' => array( |
|
215 | - 'nav' => array( |
|
216 | - 'label' => esc_html__('Privacy', 'event_espresso'), |
|
217 | - 'order' => 80 |
|
218 | - ), |
|
219 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
220 | - 'require_nonce' => false |
|
221 | - ) |
|
222 | - ); |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - protected function _add_screen_options() |
|
227 | - { |
|
228 | - } |
|
229 | - |
|
230 | - protected function _add_feature_pointers() |
|
231 | - { |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
237 | - */ |
|
238 | - public function load_scripts_styles() |
|
239 | - { |
|
240 | - // styles |
|
241 | - wp_enqueue_style('espresso-ui-theme'); |
|
242 | - // scripts |
|
243 | - wp_enqueue_script('ee_admin_js'); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * Execute logic running on `admin_init` |
|
249 | - */ |
|
250 | - public function admin_init() |
|
251 | - { |
|
252 | - EE_Registry::$i18n_js_strings['invalid_server_response'] = __( |
|
253 | - 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
254 | - 'event_espresso' |
|
255 | - ); |
|
256 | - EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
257 | - 'An error occurred! Please refresh the page and try again.', |
|
258 | - 'event_espresso' |
|
259 | - ); |
|
260 | - EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
261 | - 'Are you sure you want to delete this State / Province?', |
|
262 | - 'event_espresso' |
|
263 | - ); |
|
264 | - $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
265 | - EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
266 | - 'admin-ajax.php?page=espresso_general_settings', |
|
267 | - $protocol |
|
268 | - ); |
|
269 | - } |
|
270 | - |
|
271 | - public function admin_notices() |
|
272 | - { |
|
273 | - } |
|
274 | - |
|
275 | - public function admin_footer_scripts() |
|
276 | - { |
|
277 | - } |
|
278 | - |
|
279 | - |
|
280 | - /** |
|
281 | - * Enqueue scripts and styles for the default route. |
|
282 | - */ |
|
283 | - public function load_scripts_styles_default() |
|
284 | - { |
|
285 | - // styles |
|
286 | - wp_enqueue_style('thickbox'); |
|
287 | - // scripts |
|
288 | - wp_enqueue_script('media-upload'); |
|
289 | - wp_enqueue_script('thickbox'); |
|
290 | - wp_register_script( |
|
291 | - 'organization_settings', |
|
292 | - GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
293 | - array('jquery', 'media-upload', 'thickbox'), |
|
294 | - EVENT_ESPRESSO_VERSION, |
|
295 | - true |
|
296 | - ); |
|
297 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
298 | - wp_enqueue_script('organization_settings'); |
|
299 | - wp_enqueue_style('organization-css'); |
|
300 | - $confirm_image_delete = array( |
|
301 | - 'text' => __( |
|
302 | - 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
303 | - 'event_espresso' |
|
304 | - ), |
|
305 | - ); |
|
306 | - wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * Enqueue scripts and styles for the country settings route. |
|
312 | - */ |
|
313 | - public function load_scripts_styles_country_settings() |
|
314 | - { |
|
315 | - // scripts |
|
316 | - wp_register_script( |
|
317 | - 'gen_settings_countries', |
|
318 | - GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
319 | - array('ee_admin_js'), |
|
320 | - EVENT_ESPRESSO_VERSION, |
|
321 | - true |
|
322 | - ); |
|
323 | - wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
324 | - wp_enqueue_script('gen_settings_countries'); |
|
325 | - wp_enqueue_style('organization-css'); |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - /************* Espresso Pages *************/ |
|
330 | - /** |
|
331 | - * _espresso_page_settings |
|
332 | - * |
|
333 | - * @throws \EE_Error |
|
334 | - * @throws DomainException |
|
335 | - * @throws DomainException |
|
336 | - * @throws InvalidDataTypeException |
|
337 | - * @throws InvalidArgumentException |
|
338 | - */ |
|
339 | - protected function _espresso_page_settings() |
|
340 | - { |
|
341 | - // Check to make sure all of the main pages are setup properly, |
|
342 | - // if not create the default pages and display an admin notice |
|
343 | - EEH_Activation::verify_default_pages_exist(); |
|
344 | - $this->_transient_garbage_collection(); |
|
345 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
346 | - $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
347 | - ? EE_Registry::instance()->CFG->core->reg_page_id |
|
348 | - : null; |
|
349 | - $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
350 | - ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
351 | - : false; |
|
352 | - $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
353 | - ? EE_Registry::instance()->CFG->core->txn_page_id |
|
354 | - : null; |
|
355 | - $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
356 | - ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
357 | - : false; |
|
358 | - $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
359 | - ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
360 | - : null; |
|
361 | - $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
362 | - ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
363 | - : false; |
|
364 | - $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
365 | - ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
366 | - : null; |
|
367 | - $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
368 | - ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
369 | - : false; |
|
370 | - $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
371 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
372 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
373 | - GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
374 | - $this->_template_args, |
|
375 | - true |
|
376 | - ); |
|
377 | - $this->display_admin_page_with_sidebar(); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - /** |
|
382 | - * Handler for updating espresso page settings. |
|
383 | - * |
|
384 | - * @throws EE_Error |
|
385 | - */ |
|
386 | - protected function _update_espresso_page_settings() |
|
387 | - { |
|
388 | - // capture incoming request data && set page IDs |
|
389 | - EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
390 | - ? absint($this->_req_data['reg_page_id']) |
|
391 | - : EE_Registry::instance()->CFG->core->reg_page_id; |
|
392 | - EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
393 | - ? absint($this->_req_data['txn_page_id']) |
|
394 | - : EE_Registry::instance()->CFG->core->txn_page_id; |
|
395 | - EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
396 | - ? absint($this->_req_data['thank_you_page_id']) |
|
397 | - : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
398 | - EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
399 | - ? absint($this->_req_data['cancel_page_id']) |
|
400 | - : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
401 | - |
|
402 | - EE_Registry::instance()->CFG->core = apply_filters( |
|
403 | - 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
404 | - EE_Registry::instance()->CFG->core, |
|
405 | - $this->_req_data |
|
406 | - ); |
|
407 | - $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
408 | - $this->_redirect_after_action( |
|
409 | - $this->_update_espresso_configuration( |
|
410 | - $what, |
|
411 | - EE_Registry::instance()->CFG->core, |
|
412 | - __FILE__, |
|
413 | - __FUNCTION__, |
|
414 | - __LINE__ |
|
415 | - ), |
|
416 | - $what, |
|
417 | - '', |
|
418 | - array( |
|
419 | - 'action' => 'critical_pages', |
|
420 | - ), |
|
421 | - true |
|
422 | - ); |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - /************* Your Organization *************/ |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * @throws DomainException |
|
431 | - * @throws EE_Error |
|
432 | - * @throws InvalidArgumentException |
|
433 | - * @throws InvalidDataTypeException |
|
434 | - * @throws InvalidInterfaceException |
|
435 | - */ |
|
436 | - protected function _your_organization_settings() |
|
437 | - { |
|
438 | - $this->_template_args['admin_page_content'] = ''; |
|
439 | - try { |
|
440 | - $organization_settings_form = new OrganizationSettings( |
|
441 | - EE_Registry::instance(), |
|
442 | - EE_Registry::instance()->CFG->organization, |
|
443 | - EE_Registry::instance()->CFG->core, |
|
444 | - EE_Registry::instance()->NET_CFG->core |
|
445 | - ); |
|
446 | - $this->_template_args['admin_page_content'] = $organization_settings_form->display(); |
|
447 | - } catch (Exception $e) { |
|
448 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
449 | - } |
|
450 | - $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
451 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
452 | - $this->display_admin_page_with_sidebar(); |
|
453 | - } |
|
454 | - |
|
455 | - |
|
456 | - |
|
457 | - /** |
|
458 | - * Handler for updating organization settings. |
|
459 | - * |
|
460 | - * @throws EE_Error |
|
461 | - */ |
|
462 | - protected function _update_your_organization_settings() |
|
463 | - { |
|
464 | - try { |
|
465 | - $organization_settings_form = new OrganizationSettings( |
|
466 | - EE_Registry::instance(), |
|
467 | - EE_Registry::instance()->CFG->organization, |
|
468 | - EE_Registry::instance()->CFG->core, |
|
469 | - EE_Registry::instance()->NET_CFG->core |
|
470 | - ); |
|
471 | - $success = $organization_settings_form->process($this->_req_data); |
|
472 | - EE_Registry::instance()->CFG = apply_filters( |
|
473 | - 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
474 | - EE_Registry::instance()->CFG |
|
475 | - ); |
|
476 | - } catch (Exception $e) { |
|
477 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
478 | - $success = false; |
|
479 | - } |
|
480 | - |
|
481 | - if ($success) { |
|
482 | - $success = $this->_update_espresso_configuration( |
|
483 | - esc_html__('Your Organization Settings', 'event_espresso'), |
|
484 | - EE_Registry::instance()->CFG, |
|
485 | - __FILE__, |
|
486 | - __FUNCTION__, |
|
487 | - __LINE__ |
|
488 | - ); |
|
489 | - } |
|
490 | - |
|
491 | - $this->_redirect_after_action($success, '', '', array('action' => 'default'), true); |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - |
|
496 | - /************* Admin Options *************/ |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * _admin_option_settings |
|
501 | - * |
|
502 | - * @throws \EE_Error |
|
503 | - * @throws \LogicException |
|
504 | - */ |
|
505 | - protected function _admin_option_settings() |
|
506 | - { |
|
507 | - $this->_template_args['admin_page_content'] = ''; |
|
508 | - try { |
|
509 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
510 | - // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
511 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
512 | - // also need to account for the do_action that was in the old template |
|
513 | - $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
514 | - $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
515 | - } catch (Exception $e) { |
|
516 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
517 | - } |
|
518 | - $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
519 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
520 | - $this->display_admin_page_with_sidebar(); |
|
521 | - } |
|
522 | - |
|
523 | - |
|
524 | - /** |
|
525 | - * _update_admin_option_settings |
|
526 | - * |
|
527 | - * @throws \EE_Error |
|
528 | - * @throws InvalidDataTypeException |
|
529 | - * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
530 | - * @throws \InvalidArgumentException |
|
531 | - * @throws \LogicException |
|
532 | - */ |
|
533 | - protected function _update_admin_option_settings() |
|
534 | - { |
|
535 | - try { |
|
536 | - $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
537 | - $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
538 | - EE_Registry::instance()->CFG->admin = apply_filters( |
|
539 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
540 | - EE_Registry::instance()->CFG->admin |
|
541 | - ); |
|
542 | - } catch (Exception $e) { |
|
543 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
544 | - } |
|
545 | - $this->_redirect_after_action( |
|
546 | - apply_filters( |
|
547 | - 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
548 | - $this->_update_espresso_configuration( |
|
549 | - 'Admin Options', |
|
550 | - EE_Registry::instance()->CFG->admin, |
|
551 | - __FILE__, |
|
552 | - __FUNCTION__, |
|
553 | - __LINE__ |
|
554 | - ) |
|
555 | - ), |
|
556 | - 'Admin Options', |
|
557 | - 'updated', |
|
558 | - array('action' => 'admin_option_settings') |
|
559 | - ); |
|
560 | - } |
|
561 | - |
|
562 | - |
|
563 | - /************* Countries *************/ |
|
564 | - |
|
565 | - |
|
566 | - /** |
|
567 | - * Output Country Settings view. |
|
568 | - * |
|
569 | - * @throws DomainException |
|
570 | - * @throws EE_Error |
|
571 | - */ |
|
572 | - protected function _country_settings() |
|
573 | - { |
|
574 | - $CNT_ISO_for_site = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
575 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
576 | - : 'US'; |
|
577 | - $CNT_ISO = isset($this->_req_data['country']) |
|
578 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
579 | - : $CNT_ISO_for_site; |
|
580 | - |
|
581 | - // load field generator helper |
|
582 | - |
|
583 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
584 | - |
|
585 | - $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
586 | - EE_Question::new_instance( |
|
587 | - array( |
|
588 | - 'QST_ID' => 0, |
|
589 | - 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
590 | - 'QST_system' => 'admin-country', |
|
591 | - ) |
|
592 | - ), |
|
593 | - EE_Answer::new_instance( |
|
594 | - array( |
|
595 | - 'ANS_ID' => 0, |
|
596 | - 'ANS_value' => $CNT_ISO, |
|
597 | - ) |
|
598 | - ), |
|
599 | - array( |
|
600 | - 'input_id' => 'country', |
|
601 | - 'input_name' => 'country', |
|
602 | - 'input_prefix' => '', |
|
603 | - 'append_qstn_id' => false, |
|
604 | - ) |
|
605 | - ); |
|
606 | - |
|
607 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
608 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
609 | - $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
610 | - $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
611 | - $this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site) |
|
612 | - ->name(); |
|
613 | - |
|
614 | - $this->_set_add_edit_form_tags('update_country_settings'); |
|
615 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
616 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
617 | - GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
618 | - $this->_template_args, |
|
619 | - true |
|
620 | - ); |
|
621 | - $this->display_admin_page_with_no_sidebar(); |
|
622 | - } |
|
623 | - |
|
624 | - |
|
625 | - /** |
|
626 | - * display_country_settings |
|
627 | - * |
|
628 | - * @access public |
|
629 | - * @param string $CNT_ISO |
|
630 | - * @return mixed string | array |
|
631 | - * @throws DomainException |
|
632 | - */ |
|
633 | - public function display_country_settings($CNT_ISO = '') |
|
634 | - { |
|
635 | - $CNT_ISO_for_site = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
636 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
637 | - : 'US'; |
|
638 | - |
|
639 | - $CNT_ISO = isset($this->_req_data['country']) |
|
640 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
641 | - : $CNT_ISO; |
|
642 | - if (! $CNT_ISO) { |
|
643 | - return ''; |
|
644 | - } |
|
645 | - |
|
646 | - // for ajax |
|
647 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
648 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
649 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
650 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
651 | - /** @var EE_Country $country */ |
|
652 | - $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
653 | - |
|
654 | - $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site; |
|
655 | - $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled; |
|
656 | - |
|
657 | - $country_input_types = array( |
|
658 | - 'CNT_active' => array( |
|
659 | - 'type' => 'RADIO_BTN', |
|
660 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
661 | - 'class' => '', |
|
662 | - 'options' => $this->_yes_no_values, |
|
663 | - 'use_desc_4_label' => true, |
|
664 | - ), |
|
665 | - 'CNT_ISO' => array( |
|
666 | - 'type' => 'TEXT', |
|
667 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
668 | - 'class' => 'small-text', |
|
669 | - ), |
|
670 | - 'CNT_ISO3' => array( |
|
671 | - 'type' => 'TEXT', |
|
672 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
673 | - 'class' => 'small-text', |
|
674 | - ), |
|
675 | - 'RGN_ID' => array( |
|
676 | - 'type' => 'TEXT', |
|
677 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
678 | - 'class' => 'small-text', |
|
679 | - ), |
|
680 | - 'CNT_name' => array( |
|
681 | - 'type' => 'TEXT', |
|
682 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
683 | - 'class' => 'regular-text', |
|
684 | - ), |
|
685 | - 'CNT_cur_code' => array( |
|
686 | - 'type' => 'TEXT', |
|
687 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
688 | - 'class' => 'small-text', |
|
689 | - 'disabled' => $CNT_cur_disabled |
|
690 | - ), |
|
691 | - 'CNT_cur_single' => array( |
|
692 | - 'type' => 'TEXT', |
|
693 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
694 | - 'class' => 'medium-text', |
|
695 | - 'disabled' => $CNT_cur_disabled |
|
696 | - ), |
|
697 | - 'CNT_cur_plural' => array( |
|
698 | - 'type' => 'TEXT', |
|
699 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
700 | - 'class' => 'medium-text', |
|
701 | - 'disabled' => $CNT_cur_disabled |
|
702 | - ), |
|
703 | - 'CNT_cur_sign' => array( |
|
704 | - 'type' => 'TEXT', |
|
705 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
706 | - 'class' => 'small-text', |
|
707 | - 'htmlentities' => false, |
|
708 | - 'disabled' => $CNT_cur_disabled |
|
709 | - ), |
|
710 | - 'CNT_cur_sign_b4' => array( |
|
711 | - 'type' => 'RADIO_BTN', |
|
712 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
713 | - 'class' => '', |
|
714 | - 'options' => $this->_yes_no_values, |
|
715 | - 'use_desc_4_label' => true, |
|
716 | - 'disabled' => $CNT_cur_disabled |
|
717 | - ), |
|
718 | - 'CNT_cur_dec_plc' => array( |
|
719 | - 'type' => 'RADIO_BTN', |
|
720 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
721 | - 'class' => '', |
|
722 | - 'options' => array( |
|
723 | - array('id' => 0, 'text' => ''), |
|
724 | - array('id' => 1, 'text' => ''), |
|
725 | - array('id' => 2, 'text' => ''), |
|
726 | - array('id' => 3, 'text' => ''), |
|
727 | - ), |
|
728 | - 'disabled' => $CNT_cur_disabled |
|
729 | - ), |
|
730 | - 'CNT_cur_dec_mrk' => array( |
|
731 | - 'type' => 'RADIO_BTN', |
|
732 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
733 | - 'class' => '', |
|
734 | - 'options' => array( |
|
735 | - array( |
|
736 | - 'id' => ',', |
|
737 | - 'text' => __(', (comma)', 'event_espresso'), |
|
738 | - ), |
|
739 | - array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
740 | - ), |
|
741 | - 'use_desc_4_label' => true, |
|
742 | - 'disabled' => $CNT_cur_disabled |
|
743 | - ), |
|
744 | - 'CNT_cur_thsnds' => array( |
|
745 | - 'type' => 'RADIO_BTN', |
|
746 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
747 | - 'class' => '', |
|
748 | - 'options' => array( |
|
749 | - array( |
|
750 | - 'id' => ',', |
|
751 | - 'text' => __(', (comma)', 'event_espresso'), |
|
752 | - ), |
|
753 | - array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
754 | - ), |
|
755 | - 'use_desc_4_label' => true, |
|
756 | - 'disabled' => $CNT_cur_disabled |
|
757 | - ), |
|
758 | - 'CNT_tel_code' => array( |
|
759 | - 'type' => 'TEXT', |
|
760 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
761 | - 'class' => 'small-text', |
|
762 | - ), |
|
763 | - 'CNT_is_EU' => array( |
|
764 | - 'type' => 'RADIO_BTN', |
|
765 | - 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
766 | - 'class' => '', |
|
767 | - 'options' => $this->_yes_no_values, |
|
768 | - 'use_desc_4_label' => true, |
|
769 | - ), |
|
770 | - ); |
|
771 | - $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
772 | - $country, |
|
773 | - $country_input_types |
|
774 | - ); |
|
775 | - $country_details_settings = EEH_Template::display_template( |
|
776 | - GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
777 | - $this->_template_args, |
|
778 | - true |
|
779 | - ); |
|
780 | - |
|
781 | - if (defined('DOING_AJAX')) { |
|
782 | - $notices = EE_Error::get_notices(false, false, false); |
|
783 | - echo wp_json_encode( |
|
784 | - array( |
|
785 | - 'return_data' => $country_details_settings, |
|
786 | - 'success' => $notices['success'], |
|
787 | - 'errors' => $notices['errors'], |
|
788 | - ) |
|
789 | - ); |
|
790 | - die(); |
|
791 | - } else { |
|
792 | - return $country_details_settings; |
|
793 | - } |
|
794 | - } |
|
795 | - |
|
796 | - |
|
797 | - /** |
|
798 | - * display_country_states |
|
799 | - * |
|
800 | - * @access public |
|
801 | - * @param string $CNT_ISO |
|
802 | - * @return string |
|
803 | - * @throws DomainException |
|
804 | - */ |
|
805 | - public function display_country_states($CNT_ISO = '') |
|
806 | - { |
|
807 | - |
|
808 | - $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
809 | - |
|
810 | - if (! $CNT_ISO) { |
|
811 | - return ''; |
|
812 | - } |
|
813 | - // for ajax |
|
814 | - remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
815 | - remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
816 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
817 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
818 | - $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
819 | - |
|
820 | - if ($states) { |
|
821 | - foreach ($states as $STA_ID => $state) { |
|
822 | - if ($state instanceof EE_State) { |
|
823 | - // STA_abbrev STA_name STA_active |
|
824 | - $state_input_types = array( |
|
825 | - 'STA_abbrev' => array( |
|
826 | - 'type' => 'TEXT', |
|
827 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
828 | - 'class' => 'mid-text', |
|
829 | - ), |
|
830 | - 'STA_name' => array( |
|
831 | - 'type' => 'TEXT', |
|
832 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
833 | - 'class' => 'regular-text', |
|
834 | - ), |
|
835 | - 'STA_active' => array( |
|
836 | - 'type' => 'RADIO_BTN', |
|
837 | - 'input_name' => 'states[' . $STA_ID . ']', |
|
838 | - 'options' => $this->_yes_no_values, |
|
839 | - 'use_desc_4_label' => true, |
|
840 | - ), |
|
841 | - ); |
|
842 | - $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
843 | - EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
844 | - $state, |
|
845 | - $state_input_types |
|
846 | - ); |
|
847 | - $query_args = array( |
|
848 | - 'action' => 'delete_state', |
|
849 | - 'STA_ID' => $STA_ID, |
|
850 | - 'CNT_ISO' => $CNT_ISO, |
|
851 | - 'STA_abbrev' => $state->abbrev(), |
|
852 | - ); |
|
853 | - $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
854 | - EE_Admin_Page::add_query_args_and_nonce( |
|
855 | - $query_args, |
|
856 | - GEN_SET_ADMIN_URL |
|
857 | - ); |
|
858 | - } |
|
859 | - } |
|
860 | - } else { |
|
861 | - $this->_template_args['states'] = false; |
|
862 | - } |
|
863 | - |
|
864 | - $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
865 | - array('action' => 'add_new_state'), |
|
866 | - GEN_SET_ADMIN_URL |
|
867 | - ); |
|
868 | - |
|
869 | - $state_details_settings = EEH_Template::display_template( |
|
870 | - GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
871 | - $this->_template_args, |
|
872 | - true |
|
873 | - ); |
|
874 | - |
|
875 | - if (defined('DOING_AJAX')) { |
|
876 | - $notices = EE_Error::get_notices(false, false, false); |
|
877 | - echo wp_json_encode( |
|
878 | - array( |
|
879 | - 'return_data' => $state_details_settings, |
|
880 | - 'success' => $notices['success'], |
|
881 | - 'errors' => $notices['errors'], |
|
882 | - ) |
|
883 | - ); |
|
884 | - die(); |
|
885 | - } else { |
|
886 | - return $state_details_settings; |
|
887 | - } |
|
888 | - } |
|
889 | - |
|
890 | - |
|
891 | - /** |
|
892 | - * add_new_state |
|
893 | - * |
|
894 | - * @access public |
|
895 | - * @return void |
|
896 | - * @throws EE_Error |
|
897 | - */ |
|
898 | - public function add_new_state() |
|
899 | - { |
|
900 | - |
|
901 | - $success = true; |
|
902 | - |
|
903 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
904 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
905 | - : false; |
|
906 | - if (! $CNT_ISO) { |
|
907 | - EE_Error::add_error( |
|
908 | - __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
909 | - __FILE__, |
|
910 | - __FUNCTION__, |
|
911 | - __LINE__ |
|
912 | - ); |
|
913 | - $success = false; |
|
914 | - } |
|
915 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
916 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
917 | - : false; |
|
918 | - if (! $STA_abbrev) { |
|
919 | - EE_Error::add_error( |
|
920 | - __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
921 | - __FILE__, |
|
922 | - __FUNCTION__, |
|
923 | - __LINE__ |
|
924 | - ); |
|
925 | - $success = false; |
|
926 | - } |
|
927 | - $STA_name = isset($this->_req_data['STA_name']) |
|
928 | - ? sanitize_text_field($this->_req_data['STA_name']) |
|
929 | - : false; |
|
930 | - if (! $STA_name) { |
|
931 | - EE_Error::add_error( |
|
932 | - __('No State name or an invalid State name was received.', 'event_espresso'), |
|
933 | - __FILE__, |
|
934 | - __FUNCTION__, |
|
935 | - __LINE__ |
|
936 | - ); |
|
937 | - $success = false; |
|
938 | - } |
|
939 | - |
|
940 | - if ($success) { |
|
941 | - $cols_n_values = array( |
|
942 | - 'CNT_ISO' => $CNT_ISO, |
|
943 | - 'STA_abbrev' => $STA_abbrev, |
|
944 | - 'STA_name' => $STA_name, |
|
945 | - 'STA_active' => true, |
|
946 | - ); |
|
947 | - $success = EEM_State::instance()->insert($cols_n_values); |
|
948 | - EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
949 | - } |
|
950 | - |
|
951 | - if (defined('DOING_AJAX')) { |
|
952 | - $notices = EE_Error::get_notices(false, false, false); |
|
953 | - echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
954 | - die(); |
|
955 | - } else { |
|
956 | - $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
957 | - } |
|
958 | - } |
|
959 | - |
|
960 | - |
|
961 | - /** |
|
962 | - * delete_state |
|
963 | - * |
|
964 | - * @access public |
|
965 | - * @return boolean |
|
966 | - * @throws EE_Error |
|
967 | - * @throws EE_Error |
|
968 | - */ |
|
969 | - public function delete_state() |
|
970 | - { |
|
971 | - $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
972 | - ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
973 | - : false; |
|
974 | - $STA_ID = isset($this->_req_data['STA_ID']) |
|
975 | - ? sanitize_text_field($this->_req_data['STA_ID']) |
|
976 | - : false; |
|
977 | - $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
978 | - ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
979 | - : false; |
|
980 | - if (! $STA_ID) { |
|
981 | - EE_Error::add_error( |
|
982 | - __('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
983 | - __FILE__, |
|
984 | - __FUNCTION__, |
|
985 | - __LINE__ |
|
986 | - ); |
|
987 | - return false; |
|
988 | - } |
|
989 | - |
|
990 | - $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
991 | - if ($success !== false) { |
|
992 | - do_action( |
|
993 | - 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
994 | - $CNT_ISO, |
|
995 | - $STA_ID, |
|
996 | - array('STA_abbrev' => $STA_abbrev) |
|
997 | - ); |
|
998 | - EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
999 | - } |
|
1000 | - if (defined('DOING_AJAX')) { |
|
1001 | - $notices = EE_Error::get_notices(false, false); |
|
1002 | - $notices['return_data'] = true; |
|
1003 | - echo wp_json_encode($notices); |
|
1004 | - die(); |
|
1005 | - } else { |
|
1006 | - $this->_redirect_after_action( |
|
1007 | - $success, |
|
1008 | - 'State', |
|
1009 | - 'deleted', |
|
1010 | - array('action' => 'country_settings') |
|
1011 | - ); |
|
1012 | - } |
|
1013 | - } |
|
1014 | - |
|
1015 | - |
|
1016 | - /** |
|
1017 | - * _update_country_settings |
|
1018 | - * |
|
1019 | - * @access protected |
|
1020 | - * @return void |
|
1021 | - * @throws EE_Error |
|
1022 | - */ |
|
1023 | - protected function _update_country_settings() |
|
1024 | - { |
|
1025 | - // grab the country ISO code |
|
1026 | - $CNT_ISO = isset($this->_req_data['country']) |
|
1027 | - ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
1028 | - : false; |
|
1029 | - if (! $CNT_ISO) { |
|
1030 | - EE_Error::add_error( |
|
1031 | - __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1032 | - __FILE__, |
|
1033 | - __FUNCTION__, |
|
1034 | - __LINE__ |
|
1035 | - ); |
|
1036 | - |
|
1037 | - return; |
|
1038 | - } |
|
1039 | - $cols_n_values = array(); |
|
1040 | - $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
1041 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
1042 | - : false; |
|
1043 | - $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1044 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1045 | - : null; |
|
1046 | - $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1047 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1048 | - : null; |
|
1049 | - $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1050 | - ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) |
|
1051 | - : 'USD'; |
|
1052 | - $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1053 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1054 | - : 'dollar'; |
|
1055 | - $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1056 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1057 | - : 'dollars'; |
|
1058 | - $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1059 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1060 | - : '$'; |
|
1061 | - $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1062 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1063 | - : true; |
|
1064 | - $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1065 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1066 | - : 2; |
|
1067 | - $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1068 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1069 | - : '.'; |
|
1070 | - $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1071 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1072 | - : ','; |
|
1073 | - $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1074 | - ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1075 | - : null; |
|
1076 | - $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1077 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1078 | - : false; |
|
1079 | - $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1080 | - ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1081 | - : false; |
|
1082 | - // allow filtering of country data |
|
1083 | - $cols_n_values = apply_filters( |
|
1084 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1085 | - $cols_n_values |
|
1086 | - ); |
|
1087 | - |
|
1088 | - // where values |
|
1089 | - $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
1090 | - // run the update |
|
1091 | - $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1092 | - |
|
1093 | - if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1094 | - // allow filtering of states data |
|
1095 | - $states = apply_filters( |
|
1096 | - 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1097 | - $this->_req_data['states'] |
|
1098 | - ); |
|
1099 | - |
|
1100 | - // loop thru state data ( looks like : states[75][STA_name] ) |
|
1101 | - foreach ($states as $STA_ID => $state) { |
|
1102 | - $cols_n_values = array( |
|
1103 | - 'CNT_ISO' => $CNT_ISO, |
|
1104 | - 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1105 | - 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1106 | - 'STA_active' => (bool) absint($state['STA_active']), |
|
1107 | - ); |
|
1108 | - // where values |
|
1109 | - $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
1110 | - // run the update |
|
1111 | - $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1112 | - if ($success !== false) { |
|
1113 | - do_action( |
|
1114 | - 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1115 | - $CNT_ISO, |
|
1116 | - $STA_ID, |
|
1117 | - $cols_n_values |
|
1118 | - ); |
|
1119 | - } |
|
1120 | - } |
|
1121 | - } |
|
1122 | - // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1123 | - if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1124 | - && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1125 | - ) { |
|
1126 | - EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1127 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
1128 | - } |
|
1129 | - |
|
1130 | - if ($success !== false) { |
|
1131 | - EE_Error::add_success( |
|
1132 | - esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1133 | - ); |
|
1134 | - } |
|
1135 | - $this->_redirect_after_action( |
|
1136 | - $success, |
|
1137 | - '', |
|
1138 | - '', |
|
1139 | - array('action' => 'country_settings', 'country' => $CNT_ISO), |
|
1140 | - true |
|
1141 | - ); |
|
1142 | - } |
|
1143 | - |
|
1144 | - |
|
1145 | - /** |
|
1146 | - * form_form_field_label_wrap |
|
1147 | - * |
|
1148 | - * @access public |
|
1149 | - * @param string $label |
|
1150 | - * @return string |
|
1151 | - */ |
|
1152 | - public function country_form_field_label_wrap($label, $required_text) |
|
1153 | - { |
|
1154 | - return ' |
|
24 | + /** |
|
25 | + * _question_group |
|
26 | + * holds the specific question group object for the question group details screen |
|
27 | + * |
|
28 | + * @var object |
|
29 | + */ |
|
30 | + protected $_question_group; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Initialize basic properties. |
|
35 | + */ |
|
36 | + protected function _init_page_props() |
|
37 | + { |
|
38 | + $this->page_slug = GEN_SET_PG_SLUG; |
|
39 | + $this->page_label = GEN_SET_LABEL; |
|
40 | + $this->_admin_base_url = GEN_SET_ADMIN_URL; |
|
41 | + $this->_admin_base_path = GEN_SET_ADMIN; |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Set ajax hooks |
|
47 | + */ |
|
48 | + protected function _ajax_hooks() |
|
49 | + { |
|
50 | + add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings')); |
|
51 | + add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states')); |
|
52 | + add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3); |
|
53 | + add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state')); |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * More page properties initialization. |
|
59 | + */ |
|
60 | + protected function _define_page_props() |
|
61 | + { |
|
62 | + $this->_admin_page_title = GEN_SET_LABEL; |
|
63 | + $this->_labels = array( |
|
64 | + 'publishbox' => __('Update Settings', 'event_espresso'), |
|
65 | + ); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Set page routes property. |
|
71 | + */ |
|
72 | + protected function _set_page_routes() |
|
73 | + { |
|
74 | + $this->_page_routes = array( |
|
75 | + |
|
76 | + 'critical_pages' => array( |
|
77 | + 'func' => '_espresso_page_settings', |
|
78 | + 'capability' => 'manage_options', |
|
79 | + ), |
|
80 | + 'update_espresso_page_settings' => array( |
|
81 | + 'func' => '_update_espresso_page_settings', |
|
82 | + 'capability' => 'manage_options', |
|
83 | + 'noheader' => true, |
|
84 | + ), |
|
85 | + 'default' => array( |
|
86 | + 'func' => '_your_organization_settings', |
|
87 | + 'capability' => 'manage_options', |
|
88 | + ), |
|
89 | + |
|
90 | + 'update_your_organization_settings' => array( |
|
91 | + 'func' => '_update_your_organization_settings', |
|
92 | + 'capability' => 'manage_options', |
|
93 | + 'noheader' => true, |
|
94 | + ), |
|
95 | + |
|
96 | + 'admin_option_settings' => array( |
|
97 | + 'func' => '_admin_option_settings', |
|
98 | + 'capability' => 'manage_options', |
|
99 | + ), |
|
100 | + |
|
101 | + 'update_admin_option_settings' => array( |
|
102 | + 'func' => '_update_admin_option_settings', |
|
103 | + 'capability' => 'manage_options', |
|
104 | + 'noheader' => true, |
|
105 | + ), |
|
106 | + |
|
107 | + 'country_settings' => array( |
|
108 | + 'func' => '_country_settings', |
|
109 | + 'capability' => 'manage_options', |
|
110 | + ), |
|
111 | + |
|
112 | + 'update_country_settings' => array( |
|
113 | + 'func' => '_update_country_settings', |
|
114 | + 'capability' => 'manage_options', |
|
115 | + 'noheader' => true, |
|
116 | + ), |
|
117 | + |
|
118 | + 'display_country_settings' => array( |
|
119 | + 'func' => 'display_country_settings', |
|
120 | + 'capability' => 'manage_options', |
|
121 | + 'noheader' => true, |
|
122 | + ), |
|
123 | + |
|
124 | + 'add_new_state' => array( |
|
125 | + 'func' => 'add_new_state', |
|
126 | + 'capability' => 'manage_options', |
|
127 | + 'noheader' => true, |
|
128 | + ), |
|
129 | + |
|
130 | + 'delete_state' => array( |
|
131 | + 'func' => 'delete_state', |
|
132 | + 'capability' => 'manage_options', |
|
133 | + 'noheader' => true, |
|
134 | + ), |
|
135 | + 'privacy_settings' => array( |
|
136 | + 'func' => 'privacySettings', |
|
137 | + 'capability' => 'manage_options', |
|
138 | + ), |
|
139 | + 'update_privacy_settings' => array( |
|
140 | + 'func' => 'updatePrivacySettings', |
|
141 | + 'capability' => 'manage_options', |
|
142 | + 'noheader' => true, |
|
143 | + 'headers_sent_route' => 'privacy_settings' |
|
144 | + ) |
|
145 | + ); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * Set page configuration property |
|
151 | + */ |
|
152 | + protected function _set_page_config() |
|
153 | + { |
|
154 | + $this->_page_config = array( |
|
155 | + 'critical_pages' => array( |
|
156 | + 'nav' => array( |
|
157 | + 'label' => __('Critical Pages', 'event_espresso'), |
|
158 | + 'order' => 50, |
|
159 | + ), |
|
160 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
161 | + 'help_tabs' => array( |
|
162 | + 'general_settings_critical_pages_help_tab' => array( |
|
163 | + 'title' => __('Critical Pages', 'event_espresso'), |
|
164 | + 'filename' => 'general_settings_critical_pages', |
|
165 | + ), |
|
166 | + ), |
|
167 | + 'help_tour' => array('Critical_Pages_Help_Tour'), |
|
168 | + 'require_nonce' => false, |
|
169 | + ), |
|
170 | + 'default' => array( |
|
171 | + 'nav' => array( |
|
172 | + 'label' => __('Your Organization', 'event_espresso'), |
|
173 | + 'order' => 20, |
|
174 | + ), |
|
175 | + 'help_tabs' => array( |
|
176 | + 'general_settings_your_organization_help_tab' => array( |
|
177 | + 'title' => __('Your Organization', 'event_espresso'), |
|
178 | + 'filename' => 'general_settings_your_organization', |
|
179 | + ), |
|
180 | + ), |
|
181 | + 'help_tour' => array('Your_Organization_Help_Tour'), |
|
182 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
183 | + 'require_nonce' => false, |
|
184 | + ), |
|
185 | + 'admin_option_settings' => array( |
|
186 | + 'nav' => array( |
|
187 | + 'label' => __('Admin Options', 'event_espresso'), |
|
188 | + 'order' => 60, |
|
189 | + ), |
|
190 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
191 | + 'help_tabs' => array( |
|
192 | + 'general_settings_admin_options_help_tab' => array( |
|
193 | + 'title' => __('Admin Options', 'event_espresso'), |
|
194 | + 'filename' => 'general_settings_admin_options', |
|
195 | + ), |
|
196 | + ), |
|
197 | + 'help_tour' => array('Admin_Options_Help_Tour'), |
|
198 | + 'require_nonce' => false, |
|
199 | + ), |
|
200 | + 'country_settings' => array( |
|
201 | + 'nav' => array( |
|
202 | + 'label' => __('Countries', 'event_espresso'), |
|
203 | + 'order' => 70, |
|
204 | + ), |
|
205 | + 'help_tabs' => array( |
|
206 | + 'general_settings_countries_help_tab' => array( |
|
207 | + 'title' => __('Countries', 'event_espresso'), |
|
208 | + 'filename' => 'general_settings_countries', |
|
209 | + ), |
|
210 | + ), |
|
211 | + 'help_tour' => array('Countries_Help_Tour'), |
|
212 | + 'require_nonce' => false, |
|
213 | + ), |
|
214 | + 'privacy_settings' => array( |
|
215 | + 'nav' => array( |
|
216 | + 'label' => esc_html__('Privacy', 'event_espresso'), |
|
217 | + 'order' => 80 |
|
218 | + ), |
|
219 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
220 | + 'require_nonce' => false |
|
221 | + ) |
|
222 | + ); |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + protected function _add_screen_options() |
|
227 | + { |
|
228 | + } |
|
229 | + |
|
230 | + protected function _add_feature_pointers() |
|
231 | + { |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * Enqueue global scripts and styles for all routes in the General Settings Admin Pages. |
|
237 | + */ |
|
238 | + public function load_scripts_styles() |
|
239 | + { |
|
240 | + // styles |
|
241 | + wp_enqueue_style('espresso-ui-theme'); |
|
242 | + // scripts |
|
243 | + wp_enqueue_script('ee_admin_js'); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * Execute logic running on `admin_init` |
|
249 | + */ |
|
250 | + public function admin_init() |
|
251 | + { |
|
252 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = __( |
|
253 | + 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', |
|
254 | + 'event_espresso' |
|
255 | + ); |
|
256 | + EE_Registry::$i18n_js_strings['error_occurred'] = __( |
|
257 | + 'An error occurred! Please refresh the page and try again.', |
|
258 | + 'event_espresso' |
|
259 | + ); |
|
260 | + EE_Registry::$i18n_js_strings['confirm_delete_state'] = __( |
|
261 | + 'Are you sure you want to delete this State / Province?', |
|
262 | + 'event_espresso' |
|
263 | + ); |
|
264 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
265 | + EE_Registry::$i18n_js_strings['ajax_url'] = admin_url( |
|
266 | + 'admin-ajax.php?page=espresso_general_settings', |
|
267 | + $protocol |
|
268 | + ); |
|
269 | + } |
|
270 | + |
|
271 | + public function admin_notices() |
|
272 | + { |
|
273 | + } |
|
274 | + |
|
275 | + public function admin_footer_scripts() |
|
276 | + { |
|
277 | + } |
|
278 | + |
|
279 | + |
|
280 | + /** |
|
281 | + * Enqueue scripts and styles for the default route. |
|
282 | + */ |
|
283 | + public function load_scripts_styles_default() |
|
284 | + { |
|
285 | + // styles |
|
286 | + wp_enqueue_style('thickbox'); |
|
287 | + // scripts |
|
288 | + wp_enqueue_script('media-upload'); |
|
289 | + wp_enqueue_script('thickbox'); |
|
290 | + wp_register_script( |
|
291 | + 'organization_settings', |
|
292 | + GEN_SET_ASSETS_URL . 'your_organization_settings.js', |
|
293 | + array('jquery', 'media-upload', 'thickbox'), |
|
294 | + EVENT_ESPRESSO_VERSION, |
|
295 | + true |
|
296 | + ); |
|
297 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
298 | + wp_enqueue_script('organization_settings'); |
|
299 | + wp_enqueue_style('organization-css'); |
|
300 | + $confirm_image_delete = array( |
|
301 | + 'text' => __( |
|
302 | + 'Do you really want to delete this image? Please remember to save your settings to complete the removal.', |
|
303 | + 'event_espresso' |
|
304 | + ), |
|
305 | + ); |
|
306 | + wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * Enqueue scripts and styles for the country settings route. |
|
312 | + */ |
|
313 | + public function load_scripts_styles_country_settings() |
|
314 | + { |
|
315 | + // scripts |
|
316 | + wp_register_script( |
|
317 | + 'gen_settings_countries', |
|
318 | + GEN_SET_ASSETS_URL . 'gen_settings_countries.js', |
|
319 | + array('ee_admin_js'), |
|
320 | + EVENT_ESPRESSO_VERSION, |
|
321 | + true |
|
322 | + ); |
|
323 | + wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION); |
|
324 | + wp_enqueue_script('gen_settings_countries'); |
|
325 | + wp_enqueue_style('organization-css'); |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + /************* Espresso Pages *************/ |
|
330 | + /** |
|
331 | + * _espresso_page_settings |
|
332 | + * |
|
333 | + * @throws \EE_Error |
|
334 | + * @throws DomainException |
|
335 | + * @throws DomainException |
|
336 | + * @throws InvalidDataTypeException |
|
337 | + * @throws InvalidArgumentException |
|
338 | + */ |
|
339 | + protected function _espresso_page_settings() |
|
340 | + { |
|
341 | + // Check to make sure all of the main pages are setup properly, |
|
342 | + // if not create the default pages and display an admin notice |
|
343 | + EEH_Activation::verify_default_pages_exist(); |
|
344 | + $this->_transient_garbage_collection(); |
|
345 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
346 | + $this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
347 | + ? EE_Registry::instance()->CFG->core->reg_page_id |
|
348 | + : null; |
|
349 | + $this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) |
|
350 | + ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) |
|
351 | + : false; |
|
352 | + $this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
353 | + ? EE_Registry::instance()->CFG->core->txn_page_id |
|
354 | + : null; |
|
355 | + $this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) |
|
356 | + ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) |
|
357 | + : false; |
|
358 | + $this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
359 | + ? EE_Registry::instance()->CFG->core->thank_you_page_id |
|
360 | + : null; |
|
361 | + $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
362 | + ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) |
|
363 | + : false; |
|
364 | + $this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
365 | + ? EE_Registry::instance()->CFG->core->cancel_page_id |
|
366 | + : null; |
|
367 | + $this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
368 | + ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) |
|
369 | + : false; |
|
370 | + $this->_set_add_edit_form_tags('update_espresso_page_settings'); |
|
371 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
372 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
373 | + GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', |
|
374 | + $this->_template_args, |
|
375 | + true |
|
376 | + ); |
|
377 | + $this->display_admin_page_with_sidebar(); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + /** |
|
382 | + * Handler for updating espresso page settings. |
|
383 | + * |
|
384 | + * @throws EE_Error |
|
385 | + */ |
|
386 | + protected function _update_espresso_page_settings() |
|
387 | + { |
|
388 | + // capture incoming request data && set page IDs |
|
389 | + EE_Registry::instance()->CFG->core->reg_page_id = isset($this->_req_data['reg_page_id']) |
|
390 | + ? absint($this->_req_data['reg_page_id']) |
|
391 | + : EE_Registry::instance()->CFG->core->reg_page_id; |
|
392 | + EE_Registry::instance()->CFG->core->txn_page_id = isset($this->_req_data['txn_page_id']) |
|
393 | + ? absint($this->_req_data['txn_page_id']) |
|
394 | + : EE_Registry::instance()->CFG->core->txn_page_id; |
|
395 | + EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id']) |
|
396 | + ? absint($this->_req_data['thank_you_page_id']) |
|
397 | + : EE_Registry::instance()->CFG->core->thank_you_page_id; |
|
398 | + EE_Registry::instance()->CFG->core->cancel_page_id = isset($this->_req_data['cancel_page_id']) |
|
399 | + ? absint($this->_req_data['cancel_page_id']) |
|
400 | + : EE_Registry::instance()->CFG->core->cancel_page_id; |
|
401 | + |
|
402 | + EE_Registry::instance()->CFG->core = apply_filters( |
|
403 | + 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', |
|
404 | + EE_Registry::instance()->CFG->core, |
|
405 | + $this->_req_data |
|
406 | + ); |
|
407 | + $what = __('Critical Pages & Shortcodes', 'event_espresso'); |
|
408 | + $this->_redirect_after_action( |
|
409 | + $this->_update_espresso_configuration( |
|
410 | + $what, |
|
411 | + EE_Registry::instance()->CFG->core, |
|
412 | + __FILE__, |
|
413 | + __FUNCTION__, |
|
414 | + __LINE__ |
|
415 | + ), |
|
416 | + $what, |
|
417 | + '', |
|
418 | + array( |
|
419 | + 'action' => 'critical_pages', |
|
420 | + ), |
|
421 | + true |
|
422 | + ); |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + /************* Your Organization *************/ |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * @throws DomainException |
|
431 | + * @throws EE_Error |
|
432 | + * @throws InvalidArgumentException |
|
433 | + * @throws InvalidDataTypeException |
|
434 | + * @throws InvalidInterfaceException |
|
435 | + */ |
|
436 | + protected function _your_organization_settings() |
|
437 | + { |
|
438 | + $this->_template_args['admin_page_content'] = ''; |
|
439 | + try { |
|
440 | + $organization_settings_form = new OrganizationSettings( |
|
441 | + EE_Registry::instance(), |
|
442 | + EE_Registry::instance()->CFG->organization, |
|
443 | + EE_Registry::instance()->CFG->core, |
|
444 | + EE_Registry::instance()->NET_CFG->core |
|
445 | + ); |
|
446 | + $this->_template_args['admin_page_content'] = $organization_settings_form->display(); |
|
447 | + } catch (Exception $e) { |
|
448 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
449 | + } |
|
450 | + $this->_set_add_edit_form_tags('update_your_organization_settings'); |
|
451 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
452 | + $this->display_admin_page_with_sidebar(); |
|
453 | + } |
|
454 | + |
|
455 | + |
|
456 | + |
|
457 | + /** |
|
458 | + * Handler for updating organization settings. |
|
459 | + * |
|
460 | + * @throws EE_Error |
|
461 | + */ |
|
462 | + protected function _update_your_organization_settings() |
|
463 | + { |
|
464 | + try { |
|
465 | + $organization_settings_form = new OrganizationSettings( |
|
466 | + EE_Registry::instance(), |
|
467 | + EE_Registry::instance()->CFG->organization, |
|
468 | + EE_Registry::instance()->CFG->core, |
|
469 | + EE_Registry::instance()->NET_CFG->core |
|
470 | + ); |
|
471 | + $success = $organization_settings_form->process($this->_req_data); |
|
472 | + EE_Registry::instance()->CFG = apply_filters( |
|
473 | + 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', |
|
474 | + EE_Registry::instance()->CFG |
|
475 | + ); |
|
476 | + } catch (Exception $e) { |
|
477 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
478 | + $success = false; |
|
479 | + } |
|
480 | + |
|
481 | + if ($success) { |
|
482 | + $success = $this->_update_espresso_configuration( |
|
483 | + esc_html__('Your Organization Settings', 'event_espresso'), |
|
484 | + EE_Registry::instance()->CFG, |
|
485 | + __FILE__, |
|
486 | + __FUNCTION__, |
|
487 | + __LINE__ |
|
488 | + ); |
|
489 | + } |
|
490 | + |
|
491 | + $this->_redirect_after_action($success, '', '', array('action' => 'default'), true); |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + |
|
496 | + /************* Admin Options *************/ |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * _admin_option_settings |
|
501 | + * |
|
502 | + * @throws \EE_Error |
|
503 | + * @throws \LogicException |
|
504 | + */ |
|
505 | + protected function _admin_option_settings() |
|
506 | + { |
|
507 | + $this->_template_args['admin_page_content'] = ''; |
|
508 | + try { |
|
509 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
510 | + // still need this for the old school form in Extend_General_Settings_Admin_Page |
|
511 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
512 | + // also need to account for the do_action that was in the old template |
|
513 | + $admin_options_settings_form->setTemplateArgs($this->_template_args); |
|
514 | + $this->_template_args['admin_page_content'] = $admin_options_settings_form->display(); |
|
515 | + } catch (Exception $e) { |
|
516 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
517 | + } |
|
518 | + $this->_set_add_edit_form_tags('update_admin_option_settings'); |
|
519 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
520 | + $this->display_admin_page_with_sidebar(); |
|
521 | + } |
|
522 | + |
|
523 | + |
|
524 | + /** |
|
525 | + * _update_admin_option_settings |
|
526 | + * |
|
527 | + * @throws \EE_Error |
|
528 | + * @throws InvalidDataTypeException |
|
529 | + * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException |
|
530 | + * @throws \InvalidArgumentException |
|
531 | + * @throws \LogicException |
|
532 | + */ |
|
533 | + protected function _update_admin_option_settings() |
|
534 | + { |
|
535 | + try { |
|
536 | + $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance()); |
|
537 | + $admin_options_settings_form->process($this->_req_data[ $admin_options_settings_form->slug() ]); |
|
538 | + EE_Registry::instance()->CFG->admin = apply_filters( |
|
539 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', |
|
540 | + EE_Registry::instance()->CFG->admin |
|
541 | + ); |
|
542 | + } catch (Exception $e) { |
|
543 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
544 | + } |
|
545 | + $this->_redirect_after_action( |
|
546 | + apply_filters( |
|
547 | + 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', |
|
548 | + $this->_update_espresso_configuration( |
|
549 | + 'Admin Options', |
|
550 | + EE_Registry::instance()->CFG->admin, |
|
551 | + __FILE__, |
|
552 | + __FUNCTION__, |
|
553 | + __LINE__ |
|
554 | + ) |
|
555 | + ), |
|
556 | + 'Admin Options', |
|
557 | + 'updated', |
|
558 | + array('action' => 'admin_option_settings') |
|
559 | + ); |
|
560 | + } |
|
561 | + |
|
562 | + |
|
563 | + /************* Countries *************/ |
|
564 | + |
|
565 | + |
|
566 | + /** |
|
567 | + * Output Country Settings view. |
|
568 | + * |
|
569 | + * @throws DomainException |
|
570 | + * @throws EE_Error |
|
571 | + */ |
|
572 | + protected function _country_settings() |
|
573 | + { |
|
574 | + $CNT_ISO_for_site = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
575 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
576 | + : 'US'; |
|
577 | + $CNT_ISO = isset($this->_req_data['country']) |
|
578 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
579 | + : $CNT_ISO_for_site; |
|
580 | + |
|
581 | + // load field generator helper |
|
582 | + |
|
583 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
584 | + |
|
585 | + $this->_template_args['countries'] = new EE_Question_Form_Input( |
|
586 | + EE_Question::new_instance( |
|
587 | + array( |
|
588 | + 'QST_ID' => 0, |
|
589 | + 'QST_display_text' => __('Select Country', 'event_espresso'), |
|
590 | + 'QST_system' => 'admin-country', |
|
591 | + ) |
|
592 | + ), |
|
593 | + EE_Answer::new_instance( |
|
594 | + array( |
|
595 | + 'ANS_ID' => 0, |
|
596 | + 'ANS_value' => $CNT_ISO, |
|
597 | + ) |
|
598 | + ), |
|
599 | + array( |
|
600 | + 'input_id' => 'country', |
|
601 | + 'input_name' => 'country', |
|
602 | + 'input_prefix' => '', |
|
603 | + 'append_qstn_id' => false, |
|
604 | + ) |
|
605 | + ); |
|
606 | + |
|
607 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
608 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
609 | + $this->_template_args['country_details_settings'] = $this->display_country_settings(); |
|
610 | + $this->_template_args['country_states_settings'] = $this->display_country_states(); |
|
611 | + $this->_template_args['CNT_name_for_site'] = EEM_Country::instance()->get_one_by_ID($CNT_ISO_for_site) |
|
612 | + ->name(); |
|
613 | + |
|
614 | + $this->_set_add_edit_form_tags('update_country_settings'); |
|
615 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
616 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
617 | + GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', |
|
618 | + $this->_template_args, |
|
619 | + true |
|
620 | + ); |
|
621 | + $this->display_admin_page_with_no_sidebar(); |
|
622 | + } |
|
623 | + |
|
624 | + |
|
625 | + /** |
|
626 | + * display_country_settings |
|
627 | + * |
|
628 | + * @access public |
|
629 | + * @param string $CNT_ISO |
|
630 | + * @return mixed string | array |
|
631 | + * @throws DomainException |
|
632 | + */ |
|
633 | + public function display_country_settings($CNT_ISO = '') |
|
634 | + { |
|
635 | + $CNT_ISO_for_site = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
636 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
637 | + : 'US'; |
|
638 | + |
|
639 | + $CNT_ISO = isset($this->_req_data['country']) |
|
640 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
641 | + : $CNT_ISO; |
|
642 | + if (! $CNT_ISO) { |
|
643 | + return ''; |
|
644 | + } |
|
645 | + |
|
646 | + // for ajax |
|
647 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
648 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
649 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2); |
|
650 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2); |
|
651 | + /** @var EE_Country $country */ |
|
652 | + $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO); |
|
653 | + |
|
654 | + $CNT_cur_disabled = $CNT_ISO !== $CNT_ISO_for_site; |
|
655 | + $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled; |
|
656 | + |
|
657 | + $country_input_types = array( |
|
658 | + 'CNT_active' => array( |
|
659 | + 'type' => 'RADIO_BTN', |
|
660 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
661 | + 'class' => '', |
|
662 | + 'options' => $this->_yes_no_values, |
|
663 | + 'use_desc_4_label' => true, |
|
664 | + ), |
|
665 | + 'CNT_ISO' => array( |
|
666 | + 'type' => 'TEXT', |
|
667 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
668 | + 'class' => 'small-text', |
|
669 | + ), |
|
670 | + 'CNT_ISO3' => array( |
|
671 | + 'type' => 'TEXT', |
|
672 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
673 | + 'class' => 'small-text', |
|
674 | + ), |
|
675 | + 'RGN_ID' => array( |
|
676 | + 'type' => 'TEXT', |
|
677 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
678 | + 'class' => 'small-text', |
|
679 | + ), |
|
680 | + 'CNT_name' => array( |
|
681 | + 'type' => 'TEXT', |
|
682 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
683 | + 'class' => 'regular-text', |
|
684 | + ), |
|
685 | + 'CNT_cur_code' => array( |
|
686 | + 'type' => 'TEXT', |
|
687 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
688 | + 'class' => 'small-text', |
|
689 | + 'disabled' => $CNT_cur_disabled |
|
690 | + ), |
|
691 | + 'CNT_cur_single' => array( |
|
692 | + 'type' => 'TEXT', |
|
693 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
694 | + 'class' => 'medium-text', |
|
695 | + 'disabled' => $CNT_cur_disabled |
|
696 | + ), |
|
697 | + 'CNT_cur_plural' => array( |
|
698 | + 'type' => 'TEXT', |
|
699 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
700 | + 'class' => 'medium-text', |
|
701 | + 'disabled' => $CNT_cur_disabled |
|
702 | + ), |
|
703 | + 'CNT_cur_sign' => array( |
|
704 | + 'type' => 'TEXT', |
|
705 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
706 | + 'class' => 'small-text', |
|
707 | + 'htmlentities' => false, |
|
708 | + 'disabled' => $CNT_cur_disabled |
|
709 | + ), |
|
710 | + 'CNT_cur_sign_b4' => array( |
|
711 | + 'type' => 'RADIO_BTN', |
|
712 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
713 | + 'class' => '', |
|
714 | + 'options' => $this->_yes_no_values, |
|
715 | + 'use_desc_4_label' => true, |
|
716 | + 'disabled' => $CNT_cur_disabled |
|
717 | + ), |
|
718 | + 'CNT_cur_dec_plc' => array( |
|
719 | + 'type' => 'RADIO_BTN', |
|
720 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
721 | + 'class' => '', |
|
722 | + 'options' => array( |
|
723 | + array('id' => 0, 'text' => ''), |
|
724 | + array('id' => 1, 'text' => ''), |
|
725 | + array('id' => 2, 'text' => ''), |
|
726 | + array('id' => 3, 'text' => ''), |
|
727 | + ), |
|
728 | + 'disabled' => $CNT_cur_disabled |
|
729 | + ), |
|
730 | + 'CNT_cur_dec_mrk' => array( |
|
731 | + 'type' => 'RADIO_BTN', |
|
732 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
733 | + 'class' => '', |
|
734 | + 'options' => array( |
|
735 | + array( |
|
736 | + 'id' => ',', |
|
737 | + 'text' => __(', (comma)', 'event_espresso'), |
|
738 | + ), |
|
739 | + array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
740 | + ), |
|
741 | + 'use_desc_4_label' => true, |
|
742 | + 'disabled' => $CNT_cur_disabled |
|
743 | + ), |
|
744 | + 'CNT_cur_thsnds' => array( |
|
745 | + 'type' => 'RADIO_BTN', |
|
746 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
747 | + 'class' => '', |
|
748 | + 'options' => array( |
|
749 | + array( |
|
750 | + 'id' => ',', |
|
751 | + 'text' => __(', (comma)', 'event_espresso'), |
|
752 | + ), |
|
753 | + array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')), |
|
754 | + ), |
|
755 | + 'use_desc_4_label' => true, |
|
756 | + 'disabled' => $CNT_cur_disabled |
|
757 | + ), |
|
758 | + 'CNT_tel_code' => array( |
|
759 | + 'type' => 'TEXT', |
|
760 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
761 | + 'class' => 'small-text', |
|
762 | + ), |
|
763 | + 'CNT_is_EU' => array( |
|
764 | + 'type' => 'RADIO_BTN', |
|
765 | + 'input_name' => 'cntry[' . $CNT_ISO . ']', |
|
766 | + 'class' => '', |
|
767 | + 'options' => $this->_yes_no_values, |
|
768 | + 'use_desc_4_label' => true, |
|
769 | + ), |
|
770 | + ); |
|
771 | + $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
772 | + $country, |
|
773 | + $country_input_types |
|
774 | + ); |
|
775 | + $country_details_settings = EEH_Template::display_template( |
|
776 | + GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', |
|
777 | + $this->_template_args, |
|
778 | + true |
|
779 | + ); |
|
780 | + |
|
781 | + if (defined('DOING_AJAX')) { |
|
782 | + $notices = EE_Error::get_notices(false, false, false); |
|
783 | + echo wp_json_encode( |
|
784 | + array( |
|
785 | + 'return_data' => $country_details_settings, |
|
786 | + 'success' => $notices['success'], |
|
787 | + 'errors' => $notices['errors'], |
|
788 | + ) |
|
789 | + ); |
|
790 | + die(); |
|
791 | + } else { |
|
792 | + return $country_details_settings; |
|
793 | + } |
|
794 | + } |
|
795 | + |
|
796 | + |
|
797 | + /** |
|
798 | + * display_country_states |
|
799 | + * |
|
800 | + * @access public |
|
801 | + * @param string $CNT_ISO |
|
802 | + * @return string |
|
803 | + * @throws DomainException |
|
804 | + */ |
|
805 | + public function display_country_states($CNT_ISO = '') |
|
806 | + { |
|
807 | + |
|
808 | + $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO; |
|
809 | + |
|
810 | + if (! $CNT_ISO) { |
|
811 | + return ''; |
|
812 | + } |
|
813 | + // for ajax |
|
814 | + remove_all_filters('FHEE__EEH_Form_Fields__label_html'); |
|
815 | + remove_all_filters('FHEE__EEH_Form_Fields__input_html'); |
|
816 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2); |
|
817 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2); |
|
818 | + $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO)); |
|
819 | + |
|
820 | + if ($states) { |
|
821 | + foreach ($states as $STA_ID => $state) { |
|
822 | + if ($state instanceof EE_State) { |
|
823 | + // STA_abbrev STA_name STA_active |
|
824 | + $state_input_types = array( |
|
825 | + 'STA_abbrev' => array( |
|
826 | + 'type' => 'TEXT', |
|
827 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
828 | + 'class' => 'mid-text', |
|
829 | + ), |
|
830 | + 'STA_name' => array( |
|
831 | + 'type' => 'TEXT', |
|
832 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
833 | + 'class' => 'regular-text', |
|
834 | + ), |
|
835 | + 'STA_active' => array( |
|
836 | + 'type' => 'RADIO_BTN', |
|
837 | + 'input_name' => 'states[' . $STA_ID . ']', |
|
838 | + 'options' => $this->_yes_no_values, |
|
839 | + 'use_desc_4_label' => true, |
|
840 | + ), |
|
841 | + ); |
|
842 | + $this->_template_args['states'][ $STA_ID ]['inputs'] = |
|
843 | + EE_Question_Form_Input::generate_question_form_inputs_for_object( |
|
844 | + $state, |
|
845 | + $state_input_types |
|
846 | + ); |
|
847 | + $query_args = array( |
|
848 | + 'action' => 'delete_state', |
|
849 | + 'STA_ID' => $STA_ID, |
|
850 | + 'CNT_ISO' => $CNT_ISO, |
|
851 | + 'STA_abbrev' => $state->abbrev(), |
|
852 | + ); |
|
853 | + $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = |
|
854 | + EE_Admin_Page::add_query_args_and_nonce( |
|
855 | + $query_args, |
|
856 | + GEN_SET_ADMIN_URL |
|
857 | + ); |
|
858 | + } |
|
859 | + } |
|
860 | + } else { |
|
861 | + $this->_template_args['states'] = false; |
|
862 | + } |
|
863 | + |
|
864 | + $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
865 | + array('action' => 'add_new_state'), |
|
866 | + GEN_SET_ADMIN_URL |
|
867 | + ); |
|
868 | + |
|
869 | + $state_details_settings = EEH_Template::display_template( |
|
870 | + GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', |
|
871 | + $this->_template_args, |
|
872 | + true |
|
873 | + ); |
|
874 | + |
|
875 | + if (defined('DOING_AJAX')) { |
|
876 | + $notices = EE_Error::get_notices(false, false, false); |
|
877 | + echo wp_json_encode( |
|
878 | + array( |
|
879 | + 'return_data' => $state_details_settings, |
|
880 | + 'success' => $notices['success'], |
|
881 | + 'errors' => $notices['errors'], |
|
882 | + ) |
|
883 | + ); |
|
884 | + die(); |
|
885 | + } else { |
|
886 | + return $state_details_settings; |
|
887 | + } |
|
888 | + } |
|
889 | + |
|
890 | + |
|
891 | + /** |
|
892 | + * add_new_state |
|
893 | + * |
|
894 | + * @access public |
|
895 | + * @return void |
|
896 | + * @throws EE_Error |
|
897 | + */ |
|
898 | + public function add_new_state() |
|
899 | + { |
|
900 | + |
|
901 | + $success = true; |
|
902 | + |
|
903 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
904 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
905 | + : false; |
|
906 | + if (! $CNT_ISO) { |
|
907 | + EE_Error::add_error( |
|
908 | + __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
909 | + __FILE__, |
|
910 | + __FUNCTION__, |
|
911 | + __LINE__ |
|
912 | + ); |
|
913 | + $success = false; |
|
914 | + } |
|
915 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
916 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
917 | + : false; |
|
918 | + if (! $STA_abbrev) { |
|
919 | + EE_Error::add_error( |
|
920 | + __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), |
|
921 | + __FILE__, |
|
922 | + __FUNCTION__, |
|
923 | + __LINE__ |
|
924 | + ); |
|
925 | + $success = false; |
|
926 | + } |
|
927 | + $STA_name = isset($this->_req_data['STA_name']) |
|
928 | + ? sanitize_text_field($this->_req_data['STA_name']) |
|
929 | + : false; |
|
930 | + if (! $STA_name) { |
|
931 | + EE_Error::add_error( |
|
932 | + __('No State name or an invalid State name was received.', 'event_espresso'), |
|
933 | + __FILE__, |
|
934 | + __FUNCTION__, |
|
935 | + __LINE__ |
|
936 | + ); |
|
937 | + $success = false; |
|
938 | + } |
|
939 | + |
|
940 | + if ($success) { |
|
941 | + $cols_n_values = array( |
|
942 | + 'CNT_ISO' => $CNT_ISO, |
|
943 | + 'STA_abbrev' => $STA_abbrev, |
|
944 | + 'STA_name' => $STA_name, |
|
945 | + 'STA_active' => true, |
|
946 | + ); |
|
947 | + $success = EEM_State::instance()->insert($cols_n_values); |
|
948 | + EE_Error::add_success(__('The State was added successfully.', 'event_espresso')); |
|
949 | + } |
|
950 | + |
|
951 | + if (defined('DOING_AJAX')) { |
|
952 | + $notices = EE_Error::get_notices(false, false, false); |
|
953 | + echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO))); |
|
954 | + die(); |
|
955 | + } else { |
|
956 | + $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings')); |
|
957 | + } |
|
958 | + } |
|
959 | + |
|
960 | + |
|
961 | + /** |
|
962 | + * delete_state |
|
963 | + * |
|
964 | + * @access public |
|
965 | + * @return boolean |
|
966 | + * @throws EE_Error |
|
967 | + * @throws EE_Error |
|
968 | + */ |
|
969 | + public function delete_state() |
|
970 | + { |
|
971 | + $CNT_ISO = isset($this->_req_data['CNT_ISO']) |
|
972 | + ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) |
|
973 | + : false; |
|
974 | + $STA_ID = isset($this->_req_data['STA_ID']) |
|
975 | + ? sanitize_text_field($this->_req_data['STA_ID']) |
|
976 | + : false; |
|
977 | + $STA_abbrev = isset($this->_req_data['STA_abbrev']) |
|
978 | + ? sanitize_text_field($this->_req_data['STA_abbrev']) |
|
979 | + : false; |
|
980 | + if (! $STA_ID) { |
|
981 | + EE_Error::add_error( |
|
982 | + __('No State ID or an invalid State ID was received.', 'event_espresso'), |
|
983 | + __FILE__, |
|
984 | + __FUNCTION__, |
|
985 | + __LINE__ |
|
986 | + ); |
|
987 | + return false; |
|
988 | + } |
|
989 | + |
|
990 | + $success = EEM_State::instance()->delete_by_ID($STA_ID); |
|
991 | + if ($success !== false) { |
|
992 | + do_action( |
|
993 | + 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', |
|
994 | + $CNT_ISO, |
|
995 | + $STA_ID, |
|
996 | + array('STA_abbrev' => $STA_abbrev) |
|
997 | + ); |
|
998 | + EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso')); |
|
999 | + } |
|
1000 | + if (defined('DOING_AJAX')) { |
|
1001 | + $notices = EE_Error::get_notices(false, false); |
|
1002 | + $notices['return_data'] = true; |
|
1003 | + echo wp_json_encode($notices); |
|
1004 | + die(); |
|
1005 | + } else { |
|
1006 | + $this->_redirect_after_action( |
|
1007 | + $success, |
|
1008 | + 'State', |
|
1009 | + 'deleted', |
|
1010 | + array('action' => 'country_settings') |
|
1011 | + ); |
|
1012 | + } |
|
1013 | + } |
|
1014 | + |
|
1015 | + |
|
1016 | + /** |
|
1017 | + * _update_country_settings |
|
1018 | + * |
|
1019 | + * @access protected |
|
1020 | + * @return void |
|
1021 | + * @throws EE_Error |
|
1022 | + */ |
|
1023 | + protected function _update_country_settings() |
|
1024 | + { |
|
1025 | + // grab the country ISO code |
|
1026 | + $CNT_ISO = isset($this->_req_data['country']) |
|
1027 | + ? strtoupper(sanitize_text_field($this->_req_data['country'])) |
|
1028 | + : false; |
|
1029 | + if (! $CNT_ISO) { |
|
1030 | + EE_Error::add_error( |
|
1031 | + __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), |
|
1032 | + __FILE__, |
|
1033 | + __FUNCTION__, |
|
1034 | + __LINE__ |
|
1035 | + ); |
|
1036 | + |
|
1037 | + return; |
|
1038 | + } |
|
1039 | + $cols_n_values = array(); |
|
1040 | + $cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3']) |
|
1041 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_ISO3'])) |
|
1042 | + : false; |
|
1043 | + $cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1044 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['RGN_ID']) |
|
1045 | + : null; |
|
1046 | + $cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1047 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_name']) |
|
1048 | + : null; |
|
1049 | + $cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code']) |
|
1050 | + ? strtoupper(sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_code'])) |
|
1051 | + : 'USD'; |
|
1052 | + $cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1053 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_single']) |
|
1054 | + : 'dollar'; |
|
1055 | + $cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1056 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_plural']) |
|
1057 | + : 'dollars'; |
|
1058 | + $cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1059 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign']) |
|
1060 | + : '$'; |
|
1061 | + $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1062 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_sign_b4']) |
|
1063 | + : true; |
|
1064 | + $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1065 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_plc']) |
|
1066 | + : 2; |
|
1067 | + $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1068 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_dec_mrk']) |
|
1069 | + : '.'; |
|
1070 | + $cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1071 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_cur_thsnds']) |
|
1072 | + : ','; |
|
1073 | + $cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1074 | + ? sanitize_text_field($this->_req_data['cntry'][ $CNT_ISO ]['CNT_tel_code']) |
|
1075 | + : null; |
|
1076 | + $cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1077 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_is_EU']) |
|
1078 | + : false; |
|
1079 | + $cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1080 | + ? absint($this->_req_data['cntry'][ $CNT_ISO ]['CNT_active']) |
|
1081 | + : false; |
|
1082 | + // allow filtering of country data |
|
1083 | + $cols_n_values = apply_filters( |
|
1084 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', |
|
1085 | + $cols_n_values |
|
1086 | + ); |
|
1087 | + |
|
1088 | + // where values |
|
1089 | + $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO)); |
|
1090 | + // run the update |
|
1091 | + $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values); |
|
1092 | + |
|
1093 | + if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) { |
|
1094 | + // allow filtering of states data |
|
1095 | + $states = apply_filters( |
|
1096 | + 'FHEE__General_Settings_Admin_Page___update_country_settings__states', |
|
1097 | + $this->_req_data['states'] |
|
1098 | + ); |
|
1099 | + |
|
1100 | + // loop thru state data ( looks like : states[75][STA_name] ) |
|
1101 | + foreach ($states as $STA_ID => $state) { |
|
1102 | + $cols_n_values = array( |
|
1103 | + 'CNT_ISO' => $CNT_ISO, |
|
1104 | + 'STA_abbrev' => sanitize_text_field($state['STA_abbrev']), |
|
1105 | + 'STA_name' => sanitize_text_field($state['STA_name']), |
|
1106 | + 'STA_active' => (bool) absint($state['STA_active']), |
|
1107 | + ); |
|
1108 | + // where values |
|
1109 | + $where_cols_n_values = array(array('STA_ID' => $STA_ID)); |
|
1110 | + // run the update |
|
1111 | + $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values); |
|
1112 | + if ($success !== false) { |
|
1113 | + do_action( |
|
1114 | + 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', |
|
1115 | + $CNT_ISO, |
|
1116 | + $STA_ID, |
|
1117 | + $cols_n_values |
|
1118 | + ); |
|
1119 | + } |
|
1120 | + } |
|
1121 | + } |
|
1122 | + // check if country being edited matches org option country, and if so, then update EE_Config with new settings |
|
1123 | + if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) |
|
1124 | + && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO |
|
1125 | + ) { |
|
1126 | + EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO); |
|
1127 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
1128 | + } |
|
1129 | + |
|
1130 | + if ($success !== false) { |
|
1131 | + EE_Error::add_success( |
|
1132 | + esc_html__('Country Settings updated successfully.', 'event_espresso') |
|
1133 | + ); |
|
1134 | + } |
|
1135 | + $this->_redirect_after_action( |
|
1136 | + $success, |
|
1137 | + '', |
|
1138 | + '', |
|
1139 | + array('action' => 'country_settings', 'country' => $CNT_ISO), |
|
1140 | + true |
|
1141 | + ); |
|
1142 | + } |
|
1143 | + |
|
1144 | + |
|
1145 | + /** |
|
1146 | + * form_form_field_label_wrap |
|
1147 | + * |
|
1148 | + * @access public |
|
1149 | + * @param string $label |
|
1150 | + * @return string |
|
1151 | + */ |
|
1152 | + public function country_form_field_label_wrap($label, $required_text) |
|
1153 | + { |
|
1154 | + return ' |
|
1155 | 1155 | <tr> |
1156 | 1156 | <th> |
1157 | 1157 | ' . $label . ' |
1158 | 1158 | </th>'; |
1159 | - } |
|
1160 | - |
|
1161 | - |
|
1162 | - /** |
|
1163 | - * form_form_field_input__wrap |
|
1164 | - * |
|
1165 | - * @access public |
|
1166 | - * @param string $label |
|
1167 | - * @return string |
|
1168 | - */ |
|
1169 | - public function country_form_field_input__wrap($input, $label) |
|
1170 | - { |
|
1171 | - return ' |
|
1159 | + } |
|
1160 | + |
|
1161 | + |
|
1162 | + /** |
|
1163 | + * form_form_field_input__wrap |
|
1164 | + * |
|
1165 | + * @access public |
|
1166 | + * @param string $label |
|
1167 | + * @return string |
|
1168 | + */ |
|
1169 | + public function country_form_field_input__wrap($input, $label) |
|
1170 | + { |
|
1171 | + return ' |
|
1172 | 1172 | <td class="general-settings-country-input-td"> |
1173 | 1173 | ' . $input . ' |
1174 | 1174 | </td> |
1175 | 1175 | </tr>'; |
1176 | - } |
|
1177 | - |
|
1178 | - |
|
1179 | - /** |
|
1180 | - * form_form_field_label_wrap |
|
1181 | - * |
|
1182 | - * @access public |
|
1183 | - * @param string $label |
|
1184 | - * @param string $required_text |
|
1185 | - * @return string |
|
1186 | - */ |
|
1187 | - public function state_form_field_label_wrap($label, $required_text) |
|
1188 | - { |
|
1189 | - return $required_text; |
|
1190 | - } |
|
1191 | - |
|
1192 | - |
|
1193 | - /** |
|
1194 | - * form_form_field_input__wrap |
|
1195 | - * |
|
1196 | - * @access public |
|
1197 | - * @param string $label |
|
1198 | - * @return string |
|
1199 | - */ |
|
1200 | - public function state_form_field_input__wrap($input, $label) |
|
1201 | - { |
|
1202 | - return ' |
|
1176 | + } |
|
1177 | + |
|
1178 | + |
|
1179 | + /** |
|
1180 | + * form_form_field_label_wrap |
|
1181 | + * |
|
1182 | + * @access public |
|
1183 | + * @param string $label |
|
1184 | + * @param string $required_text |
|
1185 | + * @return string |
|
1186 | + */ |
|
1187 | + public function state_form_field_label_wrap($label, $required_text) |
|
1188 | + { |
|
1189 | + return $required_text; |
|
1190 | + } |
|
1191 | + |
|
1192 | + |
|
1193 | + /** |
|
1194 | + * form_form_field_input__wrap |
|
1195 | + * |
|
1196 | + * @access public |
|
1197 | + * @param string $label |
|
1198 | + * @return string |
|
1199 | + */ |
|
1200 | + public function state_form_field_input__wrap($input, $label) |
|
1201 | + { |
|
1202 | + return ' |
|
1203 | 1203 | <td class="general-settings-country-state-input-td"> |
1204 | 1204 | ' . $input . ' |
1205 | 1205 | </td>'; |
1206 | - } |
|
1207 | - |
|
1208 | - |
|
1209 | - /***********/ |
|
1210 | - |
|
1211 | - |
|
1212 | - /** |
|
1213 | - * displays edit and view links for critical EE pages |
|
1214 | - * |
|
1215 | - * @access public |
|
1216 | - * @param int $ee_page_id |
|
1217 | - * @return string |
|
1218 | - */ |
|
1219 | - public static function edit_view_links($ee_page_id) |
|
1220 | - { |
|
1221 | - $links = '<a href="' |
|
1222 | - . add_query_arg( |
|
1223 | - array('post' => $ee_page_id, 'action' => 'edit'), |
|
1224 | - admin_url('post.php') |
|
1225 | - ) |
|
1226 | - . '" >' |
|
1227 | - . __('Edit', 'event_espresso') |
|
1228 | - . '</a>'; |
|
1229 | - $links .= ' | '; |
|
1230 | - $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1231 | - |
|
1232 | - return $links; |
|
1233 | - } |
|
1234 | - |
|
1235 | - |
|
1236 | - /** |
|
1237 | - * displays page and shortcode status for critical EE pages |
|
1238 | - * |
|
1239 | - * @param WP page object $ee_page |
|
1240 | - * @return string |
|
1241 | - */ |
|
1242 | - public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1243 | - { |
|
1244 | - |
|
1245 | - // page status |
|
1246 | - if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1247 | - $pg_colour = 'green'; |
|
1248 | - $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1249 | - } else { |
|
1250 | - $pg_colour = 'red'; |
|
1251 | - $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1252 | - } |
|
1253 | - |
|
1254 | - // shortcode status |
|
1255 | - if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1256 | - $sc_colour = 'green'; |
|
1257 | - $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1258 | - } else { |
|
1259 | - $sc_colour = 'red'; |
|
1260 | - $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1261 | - } |
|
1262 | - |
|
1263 | - return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1264 | - . $pg_status |
|
1265 | - . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1266 | - } |
|
1267 | - |
|
1268 | - |
|
1269 | - /** |
|
1270 | - * generates a dropdown of all parent pages - copied from WP core |
|
1271 | - * |
|
1272 | - * @param int $default |
|
1273 | - * @param int $parent |
|
1274 | - * @param int $level |
|
1275 | - */ |
|
1276 | - public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
1277 | - { |
|
1278 | - global $wpdb; |
|
1279 | - $items = $wpdb->get_results( |
|
1280 | - $wpdb->prepare( |
|
1281 | - "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1282 | - $parent |
|
1283 | - ) |
|
1284 | - ); |
|
1285 | - |
|
1286 | - if ($items) { |
|
1287 | - foreach ($items as $item) { |
|
1288 | - $pad = str_repeat(' ', $level * 3); |
|
1289 | - if ($item->ID == $default) { |
|
1290 | - $current = ' selected="selected"'; |
|
1291 | - } else { |
|
1292 | - $current = ''; |
|
1293 | - } |
|
1294 | - |
|
1295 | - echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " |
|
1296 | - . esc_html($item->post_title) |
|
1297 | - . "</option>"; |
|
1298 | - parent_dropdown($default, $item->ID, $level + 1); |
|
1299 | - } |
|
1300 | - } |
|
1301 | - } |
|
1302 | - |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * Loads the scripts for the privacy settings form |
|
1306 | - */ |
|
1307 | - public function load_scripts_styles_privacy_settings() |
|
1308 | - { |
|
1309 | - $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1310 | - $form_handler->enqueueStylesAndScripts(); |
|
1311 | - } |
|
1312 | - |
|
1313 | - |
|
1314 | - /** |
|
1315 | - * display the privacy settings form |
|
1316 | - */ |
|
1317 | - public function privacySettings() |
|
1318 | - { |
|
1319 | - $this->_set_add_edit_form_tags('update_privacy_settings'); |
|
1320 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1321 | - $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1322 | - $this->_template_args['admin_page_content'] = $form_handler->display(); |
|
1323 | - $this->display_admin_page_with_sidebar(); |
|
1324 | - } |
|
1325 | - |
|
1326 | - |
|
1327 | - /** |
|
1328 | - * Update the privacy settings from form data |
|
1329 | - * |
|
1330 | - * @throws EE_Error |
|
1331 | - */ |
|
1332 | - public function updatePrivacySettings() |
|
1333 | - { |
|
1334 | - $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1335 | - $success = $form_handler->process($this->get_request_data()); |
|
1336 | - $this->_redirect_after_action( |
|
1337 | - $success, |
|
1338 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1339 | - 'updated', |
|
1340 | - array('action' => 'privacy_settings') |
|
1341 | - ); |
|
1342 | - } |
|
1206 | + } |
|
1207 | + |
|
1208 | + |
|
1209 | + /***********/ |
|
1210 | + |
|
1211 | + |
|
1212 | + /** |
|
1213 | + * displays edit and view links for critical EE pages |
|
1214 | + * |
|
1215 | + * @access public |
|
1216 | + * @param int $ee_page_id |
|
1217 | + * @return string |
|
1218 | + */ |
|
1219 | + public static function edit_view_links($ee_page_id) |
|
1220 | + { |
|
1221 | + $links = '<a href="' |
|
1222 | + . add_query_arg( |
|
1223 | + array('post' => $ee_page_id, 'action' => 'edit'), |
|
1224 | + admin_url('post.php') |
|
1225 | + ) |
|
1226 | + . '" >' |
|
1227 | + . __('Edit', 'event_espresso') |
|
1228 | + . '</a>'; |
|
1229 | + $links .= ' | '; |
|
1230 | + $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>'; |
|
1231 | + |
|
1232 | + return $links; |
|
1233 | + } |
|
1234 | + |
|
1235 | + |
|
1236 | + /** |
|
1237 | + * displays page and shortcode status for critical EE pages |
|
1238 | + * |
|
1239 | + * @param WP page object $ee_page |
|
1240 | + * @return string |
|
1241 | + */ |
|
1242 | + public static function page_and_shortcode_status($ee_page, $shortcode) |
|
1243 | + { |
|
1244 | + |
|
1245 | + // page status |
|
1246 | + if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') { |
|
1247 | + $pg_colour = 'green'; |
|
1248 | + $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), ' ', ' '); |
|
1249 | + } else { |
|
1250 | + $pg_colour = 'red'; |
|
1251 | + $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), ' ', ' '); |
|
1252 | + } |
|
1253 | + |
|
1254 | + // shortcode status |
|
1255 | + if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) { |
|
1256 | + $sc_colour = 'green'; |
|
1257 | + $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), ' '); |
|
1258 | + } else { |
|
1259 | + $sc_colour = 'red'; |
|
1260 | + $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), ' '); |
|
1261 | + } |
|
1262 | + |
|
1263 | + return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' |
|
1264 | + . $pg_status |
|
1265 | + . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>'; |
|
1266 | + } |
|
1267 | + |
|
1268 | + |
|
1269 | + /** |
|
1270 | + * generates a dropdown of all parent pages - copied from WP core |
|
1271 | + * |
|
1272 | + * @param int $default |
|
1273 | + * @param int $parent |
|
1274 | + * @param int $level |
|
1275 | + */ |
|
1276 | + public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) |
|
1277 | + { |
|
1278 | + global $wpdb; |
|
1279 | + $items = $wpdb->get_results( |
|
1280 | + $wpdb->prepare( |
|
1281 | + "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", |
|
1282 | + $parent |
|
1283 | + ) |
|
1284 | + ); |
|
1285 | + |
|
1286 | + if ($items) { |
|
1287 | + foreach ($items as $item) { |
|
1288 | + $pad = str_repeat(' ', $level * 3); |
|
1289 | + if ($item->ID == $default) { |
|
1290 | + $current = ' selected="selected"'; |
|
1291 | + } else { |
|
1292 | + $current = ''; |
|
1293 | + } |
|
1294 | + |
|
1295 | + echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " |
|
1296 | + . esc_html($item->post_title) |
|
1297 | + . "</option>"; |
|
1298 | + parent_dropdown($default, $item->ID, $level + 1); |
|
1299 | + } |
|
1300 | + } |
|
1301 | + } |
|
1302 | + |
|
1303 | + |
|
1304 | + /** |
|
1305 | + * Loads the scripts for the privacy settings form |
|
1306 | + */ |
|
1307 | + public function load_scripts_styles_privacy_settings() |
|
1308 | + { |
|
1309 | + $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1310 | + $form_handler->enqueueStylesAndScripts(); |
|
1311 | + } |
|
1312 | + |
|
1313 | + |
|
1314 | + /** |
|
1315 | + * display the privacy settings form |
|
1316 | + */ |
|
1317 | + public function privacySettings() |
|
1318 | + { |
|
1319 | + $this->_set_add_edit_form_tags('update_privacy_settings'); |
|
1320 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1321 | + $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1322 | + $this->_template_args['admin_page_content'] = $form_handler->display(); |
|
1323 | + $this->display_admin_page_with_sidebar(); |
|
1324 | + } |
|
1325 | + |
|
1326 | + |
|
1327 | + /** |
|
1328 | + * Update the privacy settings from form data |
|
1329 | + * |
|
1330 | + * @throws EE_Error |
|
1331 | + */ |
|
1332 | + public function updatePrivacySettings() |
|
1333 | + { |
|
1334 | + $form_handler = LoaderFactory::getLoader()->getShared('EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'); |
|
1335 | + $success = $form_handler->process($this->get_request_data()); |
|
1336 | + $this->_redirect_after_action( |
|
1337 | + $success, |
|
1338 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1339 | + 'updated', |
|
1340 | + array('action' => 'privacy_settings') |
|
1341 | + ); |
|
1342 | + } |
|
1343 | 1343 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | <h2 class="ee-admin-settings-hdr"> |
12 | 12 | <?php _e( |
13 | - 'Countries and States/Provinces', |
|
14 | - 'event_espresso' |
|
15 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
13 | + 'Countries and States/Provinces', |
|
14 | + 'event_espresso' |
|
15 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
16 | 16 | <table class="form-table"> |
17 | 17 | <tbody> |
18 | 18 | <?php echo EEH_Form_Fields::generate_form_input($countries); ?> |
@@ -21,38 +21,38 @@ discard block |
||
21 | 21 | <br/> |
22 | 22 | <p> |
23 | 23 | <?php |
24 | - esc_html_e( |
|
25 | - 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
26 | - 'event_espresso' |
|
27 | - ); |
|
28 | - ?> |
|
24 | + esc_html_e( |
|
25 | + 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
26 | + 'event_espresso' |
|
27 | + ); |
|
28 | + ?> |
|
29 | 29 | </p> |
30 | 30 | <p id="country-currency-setting-disabled-pg" style="display: none;"> |
31 | 31 | <span class="reminder-spn"> |
32 | 32 | <?php printf( |
33 | - esc_html__( |
|
34 | - 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
35 | - 'event_espresso' |
|
36 | - ), |
|
37 | - $CNT_name_for_site |
|
38 | - ); ?> |
|
33 | + esc_html__( |
|
34 | + 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
35 | + 'event_espresso' |
|
36 | + ), |
|
37 | + $CNT_name_for_site |
|
38 | + ); ?> |
|
39 | 39 | </span> |
40 | 40 | </p> |
41 | 41 | <div id="country-details-settings-dv"> |
42 | 42 | <h2 class="ee-admin-settings-hdr"> |
43 | 43 | <?php _e( |
44 | - 'Country Details', |
|
45 | - 'event_espresso' |
|
46 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
44 | + 'Country Details', |
|
45 | + 'event_espresso' |
|
46 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
47 | 47 | <div id="country-details-dv"><?php echo $country_details_settings; ?></div> |
48 | 48 | </div> |
49 | 49 | |
50 | 50 | <div id="country-states-settings-dv"> |
51 | 51 | <h2 class="ee-admin-settings-hdr"> |
52 | 52 | <?php _e( |
53 | - 'States/Provinces', |
|
54 | - 'event_espresso' |
|
55 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
53 | + 'States/Provinces', |
|
54 | + 'event_espresso' |
|
55 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
56 | 56 | <div id="country-states-dv"><?php echo $country_states_settings; ?></div> |
57 | 57 | </div> |
58 | 58 |
@@ -8,10 +8,10 @@ |
||
8 | 8 | <table id="general-setting-country-details-tbl" class="form-table"> |
9 | 9 | <tbody> |
10 | 10 | <?php |
11 | - foreach ($inputs as $ID => $input) { |
|
12 | - echo EEH_Form_Fields::generate_form_input($input); |
|
13 | - } |
|
14 | - ?> |
|
11 | + foreach ($inputs as $ID => $input) { |
|
12 | + echo EEH_Form_Fields::generate_form_input($input); |
|
13 | + } |
|
14 | + ?> |
|
15 | 15 | <tr> |
16 | 16 | <th></th> |
17 | 17 | <td> |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct(\EEHI_File $file_helper = null) |
36 | 36 | { |
37 | - if (! $file_helper) { |
|
37 | + if ( ! $file_helper) { |
|
38 | 38 | $this->_file_helper = new EEH_File(); |
39 | 39 | } |
40 | 40 | } |
@@ -55,23 +55,23 @@ discard block |
||
55 | 55 | try { |
56 | 56 | $base_folder = $this->get_base_folder(); |
57 | 57 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
58 | - $base_folder . JobHandlerFile::temp_folder_name |
|
58 | + $base_folder.JobHandlerFile::temp_folder_name |
|
59 | 59 | ); |
60 | 60 | if ($success) { |
61 | 61 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
62 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id |
|
62 | + $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id |
|
63 | 63 | ); |
64 | 64 | } |
65 | 65 | if ($success) { |
66 | - $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename; |
|
66 | + $filepath = $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id.DS.$filename; |
|
67 | 67 | $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
68 | 68 | } |
69 | 69 | // let's add the .htaccess file so safari will open the file properly |
70 | 70 | if ($success) { |
71 | 71 | $extension = EEH_File::get_file_extension($filepath); |
72 | 72 | EEH_File::write_to_file( |
73 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess', |
|
74 | - 'AddType ' . $filetype . ' ' . $extension, |
|
73 | + $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id.DS.'.htaccess', |
|
74 | + 'AddType '.$filetype.' '.$extension, |
|
75 | 75 | '.htaccess' |
76 | 76 | ); |
77 | 77 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | ) |
95 | 95 | ); |
96 | 96 | // those methods normally fail with an exception, but if not, let's do it |
97 | - if (! $success) { |
|
97 | + if ( ! $success) { |
|
98 | 98 | throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
99 | 99 | } |
100 | 100 | } catch (\EE_Error $e) { |
@@ -17,135 +17,135 @@ |
||
17 | 17 | */ |
18 | 18 | abstract class JobHandlerFile extends JobHandler |
19 | 19 | { |
20 | - // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase |
|
21 | - const temp_folder_name = 'batch_temp_folder'; |
|
20 | + // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase |
|
21 | + const temp_folder_name = 'batch_temp_folder'; |
|
22 | 22 | |
23 | - // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
24 | - /** |
|
25 | - * @var \EEHI_File |
|
26 | - */ |
|
27 | - protected $_file_helper = null; |
|
23 | + // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
24 | + /** |
|
25 | + * @var \EEHI_File |
|
26 | + */ |
|
27 | + protected $_file_helper = null; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * JobHandlerFile constructor. |
|
32 | - * |
|
33 | - * @param \EEHI_File|null $file_helper |
|
34 | - */ |
|
35 | - public function __construct(\EEHI_File $file_helper = null) |
|
36 | - { |
|
37 | - if (! $file_helper) { |
|
38 | - $this->_file_helper = new EEH_File(); |
|
39 | - } |
|
40 | - } |
|
30 | + /** |
|
31 | + * JobHandlerFile constructor. |
|
32 | + * |
|
33 | + * @param \EEHI_File|null $file_helper |
|
34 | + */ |
|
35 | + public function __construct(\EEHI_File $file_helper = null) |
|
36 | + { |
|
37 | + if (! $file_helper) { |
|
38 | + $this->_file_helper = new EEH_File(); |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
43 | - /** |
|
44 | - * Creates a file |
|
45 | - * |
|
46 | - * @param string $job_id |
|
47 | - * @param string $filename |
|
48 | - * @param string $filetype |
|
49 | - * @param string $bom initial content to place in the file. |
|
50 | - * @return string |
|
51 | - * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException |
|
52 | - */ |
|
53 | - public function create_file_from_job_with_name( |
|
54 | - $job_id, |
|
55 | - $filename, |
|
56 | - $filetype = 'application/ms-excel', |
|
57 | - $bom = "\xEF\xBB\xBF" |
|
58 | - ) { |
|
59 | - $filepath = ''; |
|
60 | - try { |
|
61 | - $base_folder = $this->get_base_folder(); |
|
62 | - $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
63 | - $base_folder . JobHandlerFile::temp_folder_name |
|
64 | - ); |
|
65 | - if ($success) { |
|
66 | - $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
67 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id |
|
68 | - ); |
|
69 | - } |
|
70 | - if ($success) { |
|
71 | - $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename; |
|
72 | - $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
73 | - } |
|
74 | - // let's add the .htaccess file so safari will open the file properly |
|
75 | - if ($success) { |
|
76 | - $extension = EEH_File::get_file_extension($filepath); |
|
77 | - EEH_File::write_to_file( |
|
78 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess', |
|
79 | - 'AddType ' . $filetype . ' ' . $extension, |
|
80 | - '.htaccess' |
|
81 | - ); |
|
82 | - } |
|
83 | - /** |
|
84 | - * Filters what initial content will be added to the file. |
|
85 | - * @param string $return_value. By default it's whatever was pased into |
|
86 | - * JobHandlerFile::create_file_from_job_with_name() |
|
87 | - * @param string $filename |
|
88 | - * @param string $filetype default 'application/ms-excel' |
|
89 | - * @param string $filepath |
|
90 | - */ |
|
91 | - EEH_File::write_to_file( |
|
92 | - $filepath, |
|
93 | - apply_filters( |
|
94 | - 'FHEE__EE_CSV__begin_sending_csv__start_writing', |
|
95 | - $bom, |
|
96 | - $filename, |
|
97 | - $filetype, |
|
98 | - $filepath |
|
99 | - ) |
|
100 | - ); |
|
101 | - // those methods normally fail with an exception, but if not, let's do it |
|
102 | - if (! $success) { |
|
103 | - throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
|
104 | - } |
|
105 | - } catch (\EE_Error $e) { |
|
106 | - throw new BatchRequestException( |
|
107 | - sprintf( |
|
108 | - // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment |
|
109 | - __('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
110 | - $job_id, |
|
111 | - $e->getMessage() |
|
112 | - ), |
|
113 | - 500, |
|
114 | - $e |
|
115 | - ); |
|
116 | - } |
|
117 | - return $filepath; |
|
118 | - } |
|
42 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
43 | + /** |
|
44 | + * Creates a file |
|
45 | + * |
|
46 | + * @param string $job_id |
|
47 | + * @param string $filename |
|
48 | + * @param string $filetype |
|
49 | + * @param string $bom initial content to place in the file. |
|
50 | + * @return string |
|
51 | + * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException |
|
52 | + */ |
|
53 | + public function create_file_from_job_with_name( |
|
54 | + $job_id, |
|
55 | + $filename, |
|
56 | + $filetype = 'application/ms-excel', |
|
57 | + $bom = "\xEF\xBB\xBF" |
|
58 | + ) { |
|
59 | + $filepath = ''; |
|
60 | + try { |
|
61 | + $base_folder = $this->get_base_folder(); |
|
62 | + $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
63 | + $base_folder . JobHandlerFile::temp_folder_name |
|
64 | + ); |
|
65 | + if ($success) { |
|
66 | + $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
67 | + $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id |
|
68 | + ); |
|
69 | + } |
|
70 | + if ($success) { |
|
71 | + $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename; |
|
72 | + $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
73 | + } |
|
74 | + // let's add the .htaccess file so safari will open the file properly |
|
75 | + if ($success) { |
|
76 | + $extension = EEH_File::get_file_extension($filepath); |
|
77 | + EEH_File::write_to_file( |
|
78 | + $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess', |
|
79 | + 'AddType ' . $filetype . ' ' . $extension, |
|
80 | + '.htaccess' |
|
81 | + ); |
|
82 | + } |
|
83 | + /** |
|
84 | + * Filters what initial content will be added to the file. |
|
85 | + * @param string $return_value. By default it's whatever was pased into |
|
86 | + * JobHandlerFile::create_file_from_job_with_name() |
|
87 | + * @param string $filename |
|
88 | + * @param string $filetype default 'application/ms-excel' |
|
89 | + * @param string $filepath |
|
90 | + */ |
|
91 | + EEH_File::write_to_file( |
|
92 | + $filepath, |
|
93 | + apply_filters( |
|
94 | + 'FHEE__EE_CSV__begin_sending_csv__start_writing', |
|
95 | + $bom, |
|
96 | + $filename, |
|
97 | + $filetype, |
|
98 | + $filepath |
|
99 | + ) |
|
100 | + ); |
|
101 | + // those methods normally fail with an exception, but if not, let's do it |
|
102 | + if (! $success) { |
|
103 | + throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
|
104 | + } |
|
105 | + } catch (\EE_Error $e) { |
|
106 | + throw new BatchRequestException( |
|
107 | + sprintf( |
|
108 | + // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment |
|
109 | + __('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
110 | + $job_id, |
|
111 | + $e->getMessage() |
|
112 | + ), |
|
113 | + 500, |
|
114 | + $e |
|
115 | + ); |
|
116 | + } |
|
117 | + return $filepath; |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Gets the URL to download the file |
|
122 | - * |
|
123 | - * @param string $filepath |
|
124 | - * @return string url to file |
|
125 | - */ |
|
126 | - public function get_url_to_file($filepath) |
|
127 | - { |
|
128 | - return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath); |
|
129 | - } |
|
120 | + /** |
|
121 | + * Gets the URL to download the file |
|
122 | + * |
|
123 | + * @param string $filepath |
|
124 | + * @return string url to file |
|
125 | + */ |
|
126 | + public function get_url_to_file($filepath) |
|
127 | + { |
|
128 | + return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * Gets the folder which will contain the "batch_temp_folder" |
|
133 | - * |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - public function get_base_folder() |
|
137 | - { |
|
138 | - return apply_filters( |
|
139 | - 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder', |
|
140 | - EVENT_ESPRESSO_UPLOAD_DIR |
|
141 | - ); |
|
142 | - } |
|
131 | + /** |
|
132 | + * Gets the folder which will contain the "batch_temp_folder" |
|
133 | + * |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + public function get_base_folder() |
|
137 | + { |
|
138 | + return apply_filters( |
|
139 | + 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder', |
|
140 | + EVENT_ESPRESSO_UPLOAD_DIR |
|
141 | + ); |
|
142 | + } |
|
143 | 143 | |
144 | - public function get_base_url() |
|
145 | - { |
|
146 | - return apply_filters( |
|
147 | - 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url', |
|
148 | - EVENT_ESPRESSO_UPLOAD_URL |
|
149 | - ); |
|
150 | - } |
|
144 | + public function get_base_url() |
|
145 | + { |
|
146 | + return apply_filters( |
|
147 | + 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url', |
|
148 | + EVENT_ESPRESSO_UPLOAD_URL |
|
149 | + ); |
|
150 | + } |
|
151 | 151 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.69.rc.008'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.69.rc.008'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
@@ -16,207 +16,207 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - protected $_event; |
|
20 | - |
|
21 | - |
|
22 | - public function __construct(EE_Admin_Page $admin_page) |
|
23 | - { |
|
24 | - parent::__construct($admin_page); |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - protected function _set_hooks_properties() |
|
29 | - { |
|
30 | - $this->_name = 'venues'; |
|
31 | - |
|
32 | - $this->_metaboxes = array( |
|
33 | - 0 => array( |
|
34 | - 'page_route' => array('edit', 'create_new'), |
|
35 | - 'func' => 'venue_metabox', |
|
36 | - 'label' => __('Venue Details', 'event_espresso'), |
|
37 | - 'priority' => 'high', |
|
38 | - 'context' => 'normal', |
|
39 | - ), |
|
40 | - );/**/ |
|
41 | - |
|
42 | - $this->_scripts_styles = array( |
|
43 | - 'registers' => array( |
|
44 | - 'ee_event_venues' => array( |
|
45 | - 'type' => 'js', |
|
46 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
47 | - 'depends' => array('jquery'), |
|
48 | - ), |
|
49 | - 'ee_event_venues_css' => array( |
|
50 | - 'type' => 'css', |
|
51 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
52 | - ), |
|
53 | - ), |
|
54 | - 'enqueues' => array( |
|
55 | - 'ee_event_venues' => array('edit', 'create_new'), |
|
56 | - 'ee_event_venues_css' => array('edit', 'create_new'), |
|
57 | - ), |
|
58 | - ); |
|
59 | - |
|
60 | - // hook into the handler for saving venue |
|
61 | - add_filter( |
|
62 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
63 | - array($this, 'modify_callbacks'), |
|
64 | - 10 |
|
65 | - ); |
|
66 | - |
|
67 | - // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
68 | - add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - public function modify_callbacks($callbacks) |
|
73 | - { |
|
74 | - // first remove default venue callback |
|
75 | - foreach ($callbacks as $key => $callback) { |
|
76 | - if ($callback[1] == '_default_venue_update') { |
|
77 | - unset($callbacks[ $key ]); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - // now let's add the caf version |
|
82 | - $callbacks[] = array($this, 'caf_venue_update'); |
|
83 | - return $callbacks; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - public function venue_metabox() |
|
88 | - { |
|
89 | - $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
90 | - $evt_id = $evt_obj->ID(); |
|
91 | - |
|
92 | - // first let's see if we have a venue already |
|
93 | - $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
94 | - $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
95 | - $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
96 | - |
|
97 | - // possibly private venues. |
|
98 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
99 | - $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
100 | - } else { |
|
101 | - $vnu_where['status'] = 'publish'; |
|
102 | - } |
|
103 | - |
|
104 | - // cap checks |
|
105 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
106 | - $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
107 | - } |
|
108 | - |
|
109 | - $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
110 | - $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
111 | - |
|
112 | - $ven_select = array(); |
|
113 | - $ven_select[0] = __('Select a Venue', 'event_espresso'); |
|
114 | - // setup venues for selector |
|
115 | - foreach ($venues as $venue) { |
|
116 | - $ven_select[ $venue->ID() ] = $venue->name(); |
|
117 | - } |
|
118 | - |
|
119 | - // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
120 | - // show existing attached venues even if it's trashed (or some other restricted status). |
|
121 | - |
|
122 | - if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
123 | - $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
124 | - $venues = array_merge($venues, array($evt_venue)); |
|
125 | - } |
|
126 | - |
|
127 | - $template_args['venues'] = $venues; |
|
128 | - $template_args['evt_venue_id'] = $evt_venue_id; |
|
129 | - $venue_selector = new EE_Select_Input( |
|
130 | - $ven_select, |
|
131 | - array( |
|
132 | - 'html_name' => 'venue_id', |
|
133 | - 'html_id' => 'venue_id', |
|
134 | - 'html_class' => 'wide', |
|
135 | - 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
136 | - ) |
|
137 | - ); |
|
138 | - $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
139 | - $enable_for_gmap = new EE_Yes_No_Input( |
|
140 | - array( |
|
141 | - 'html_name' => 'enable_for_gmap', |
|
142 | - 'html_id' => 'enable_for_gmap', |
|
143 | - 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
144 | - ) |
|
145 | - ); |
|
146 | - $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
147 | - $template_args['new_venue_link'] = EEH_HTML::link( |
|
148 | - EE_Admin_Page::add_query_args_and_nonce( |
|
149 | - array('action' => 'create_new'), |
|
150 | - EE_VENUES_ADMIN_URL |
|
151 | - ), |
|
152 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
153 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
154 | - 'ev_new_venue_link', |
|
155 | - 'button', |
|
156 | - 'margin-left:10px;', |
|
157 | - 'target="_blank"' |
|
158 | - ); |
|
159 | - |
|
160 | - // Decide on an info text when there are no venues to display. |
|
161 | - $no_venues_info_txt = esc_html_x( |
|
162 | - 'You have not created any venues yet.', |
|
163 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
164 | - 'event_espresso' |
|
165 | - ); |
|
166 | - if (empty($venues)) { |
|
167 | - $unpublished_where = $vnu_where; |
|
168 | - $unpublished_where['status'] = 'draft'; |
|
169 | - $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
170 | - if (count($unpublished_venues) > 0) { |
|
171 | - $no_venues_info_txt = esc_html_x( |
|
172 | - // @codingStandardsIgnoreStart |
|
173 | - 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
174 | - // @codingStandardsIgnoreEnd |
|
175 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
176 | - 'event_espresso' |
|
177 | - ); |
|
178 | - } |
|
179 | - } |
|
180 | - $template_args['no_venues_info'] = EEH_HTML::p( |
|
181 | - EEH_HTML::strong($no_venues_info_txt), |
|
182 | - 'no_venues_info', |
|
183 | - 'info' |
|
184 | - ); |
|
185 | - |
|
186 | - $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
187 | - : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
188 | - |
|
189 | - // Allow events venue metabox template args filtering. |
|
190 | - $template_args = apply_filters( |
|
191 | - 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
192 | - $template_args, |
|
193 | - $template_path |
|
194 | - ); |
|
195 | - |
|
196 | - EEH_Template::display_template($template_path, $template_args); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - public function caf_venue_update($evtobj, $data) |
|
201 | - { |
|
202 | - EE_Registry::instance()->load_model('Venue'); |
|
203 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
204 | - |
|
205 | - |
|
206 | - // first let's check if the selected venue matches any existing venue attached to the event |
|
207 | - $evt_venue = $evtobj->venues(); |
|
208 | - $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
209 | - |
|
210 | - if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
211 | - $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
212 | - } |
|
213 | - |
|
214 | - if (empty($venue_id)) { |
|
215 | - return true; |
|
216 | - } //no venue to attach |
|
217 | - |
|
218 | - // this should take care of adding to revisions as well as main post object |
|
219 | - $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
220 | - return ! empty($success) ? true : false; |
|
221 | - } |
|
19 | + protected $_event; |
|
20 | + |
|
21 | + |
|
22 | + public function __construct(EE_Admin_Page $admin_page) |
|
23 | + { |
|
24 | + parent::__construct($admin_page); |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + protected function _set_hooks_properties() |
|
29 | + { |
|
30 | + $this->_name = 'venues'; |
|
31 | + |
|
32 | + $this->_metaboxes = array( |
|
33 | + 0 => array( |
|
34 | + 'page_route' => array('edit', 'create_new'), |
|
35 | + 'func' => 'venue_metabox', |
|
36 | + 'label' => __('Venue Details', 'event_espresso'), |
|
37 | + 'priority' => 'high', |
|
38 | + 'context' => 'normal', |
|
39 | + ), |
|
40 | + );/**/ |
|
41 | + |
|
42 | + $this->_scripts_styles = array( |
|
43 | + 'registers' => array( |
|
44 | + 'ee_event_venues' => array( |
|
45 | + 'type' => 'js', |
|
46 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
47 | + 'depends' => array('jquery'), |
|
48 | + ), |
|
49 | + 'ee_event_venues_css' => array( |
|
50 | + 'type' => 'css', |
|
51 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
52 | + ), |
|
53 | + ), |
|
54 | + 'enqueues' => array( |
|
55 | + 'ee_event_venues' => array('edit', 'create_new'), |
|
56 | + 'ee_event_venues_css' => array('edit', 'create_new'), |
|
57 | + ), |
|
58 | + ); |
|
59 | + |
|
60 | + // hook into the handler for saving venue |
|
61 | + add_filter( |
|
62 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
63 | + array($this, 'modify_callbacks'), |
|
64 | + 10 |
|
65 | + ); |
|
66 | + |
|
67 | + // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
68 | + add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + public function modify_callbacks($callbacks) |
|
73 | + { |
|
74 | + // first remove default venue callback |
|
75 | + foreach ($callbacks as $key => $callback) { |
|
76 | + if ($callback[1] == '_default_venue_update') { |
|
77 | + unset($callbacks[ $key ]); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + // now let's add the caf version |
|
82 | + $callbacks[] = array($this, 'caf_venue_update'); |
|
83 | + return $callbacks; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + public function venue_metabox() |
|
88 | + { |
|
89 | + $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
90 | + $evt_id = $evt_obj->ID(); |
|
91 | + |
|
92 | + // first let's see if we have a venue already |
|
93 | + $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
94 | + $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
95 | + $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
96 | + |
|
97 | + // possibly private venues. |
|
98 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
99 | + $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
100 | + } else { |
|
101 | + $vnu_where['status'] = 'publish'; |
|
102 | + } |
|
103 | + |
|
104 | + // cap checks |
|
105 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
106 | + $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
107 | + } |
|
108 | + |
|
109 | + $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
110 | + $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
111 | + |
|
112 | + $ven_select = array(); |
|
113 | + $ven_select[0] = __('Select a Venue', 'event_espresso'); |
|
114 | + // setup venues for selector |
|
115 | + foreach ($venues as $venue) { |
|
116 | + $ven_select[ $venue->ID() ] = $venue->name(); |
|
117 | + } |
|
118 | + |
|
119 | + // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
120 | + // show existing attached venues even if it's trashed (or some other restricted status). |
|
121 | + |
|
122 | + if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
123 | + $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
124 | + $venues = array_merge($venues, array($evt_venue)); |
|
125 | + } |
|
126 | + |
|
127 | + $template_args['venues'] = $venues; |
|
128 | + $template_args['evt_venue_id'] = $evt_venue_id; |
|
129 | + $venue_selector = new EE_Select_Input( |
|
130 | + $ven_select, |
|
131 | + array( |
|
132 | + 'html_name' => 'venue_id', |
|
133 | + 'html_id' => 'venue_id', |
|
134 | + 'html_class' => 'wide', |
|
135 | + 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
136 | + ) |
|
137 | + ); |
|
138 | + $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
139 | + $enable_for_gmap = new EE_Yes_No_Input( |
|
140 | + array( |
|
141 | + 'html_name' => 'enable_for_gmap', |
|
142 | + 'html_id' => 'enable_for_gmap', |
|
143 | + 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
144 | + ) |
|
145 | + ); |
|
146 | + $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
147 | + $template_args['new_venue_link'] = EEH_HTML::link( |
|
148 | + EE_Admin_Page::add_query_args_and_nonce( |
|
149 | + array('action' => 'create_new'), |
|
150 | + EE_VENUES_ADMIN_URL |
|
151 | + ), |
|
152 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
153 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
154 | + 'ev_new_venue_link', |
|
155 | + 'button', |
|
156 | + 'margin-left:10px;', |
|
157 | + 'target="_blank"' |
|
158 | + ); |
|
159 | + |
|
160 | + // Decide on an info text when there are no venues to display. |
|
161 | + $no_venues_info_txt = esc_html_x( |
|
162 | + 'You have not created any venues yet.', |
|
163 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
164 | + 'event_espresso' |
|
165 | + ); |
|
166 | + if (empty($venues)) { |
|
167 | + $unpublished_where = $vnu_where; |
|
168 | + $unpublished_where['status'] = 'draft'; |
|
169 | + $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
170 | + if (count($unpublished_venues) > 0) { |
|
171 | + $no_venues_info_txt = esc_html_x( |
|
172 | + // @codingStandardsIgnoreStart |
|
173 | + 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
174 | + // @codingStandardsIgnoreEnd |
|
175 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
176 | + 'event_espresso' |
|
177 | + ); |
|
178 | + } |
|
179 | + } |
|
180 | + $template_args['no_venues_info'] = EEH_HTML::p( |
|
181 | + EEH_HTML::strong($no_venues_info_txt), |
|
182 | + 'no_venues_info', |
|
183 | + 'info' |
|
184 | + ); |
|
185 | + |
|
186 | + $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
187 | + : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
188 | + |
|
189 | + // Allow events venue metabox template args filtering. |
|
190 | + $template_args = apply_filters( |
|
191 | + 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
192 | + $template_args, |
|
193 | + $template_path |
|
194 | + ); |
|
195 | + |
|
196 | + EEH_Template::display_template($template_path, $template_args); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + public function caf_venue_update($evtobj, $data) |
|
201 | + { |
|
202 | + EE_Registry::instance()->load_model('Venue'); |
|
203 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
204 | + |
|
205 | + |
|
206 | + // first let's check if the selected venue matches any existing venue attached to the event |
|
207 | + $evt_venue = $evtobj->venues(); |
|
208 | + $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
209 | + |
|
210 | + if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
211 | + $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
212 | + } |
|
213 | + |
|
214 | + if (empty($venue_id)) { |
|
215 | + return true; |
|
216 | + } //no venue to attach |
|
217 | + |
|
218 | + // this should take care of adding to revisions as well as main post object |
|
219 | + $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
220 | + return ! empty($success) ? true : false; |
|
221 | + } |
|
222 | 222 | } |