@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -143,54 +143,54 @@ discard block |
||
143 | 143 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
144 | 144 | * } |
145 | 145 | */ |
146 | - public function __construct( $input_args = array() ){ |
|
147 | - $input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
146 | + public function __construct($input_args = array()) { |
|
147 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
148 | 148 | // the following properties must be cast as arrays |
149 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
150 | - foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) { |
|
151 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
152 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
149 | + if (isset($input_args['validation_strategies'])) { |
|
150 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
151 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
152 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
153 | 153 | } |
154 | 154 | } |
155 | - unset( $input_args['validation_strategies'] ); |
|
155 | + unset($input_args['validation_strategies']); |
|
156 | 156 | } |
157 | 157 | // loop thru incoming options |
158 | - foreach( $input_args as $key => $value ) { |
|
158 | + foreach ($input_args as $key => $value) { |
|
159 | 159 | // add underscore to $key to match property names |
160 | - $_key = '_' . $key; |
|
161 | - if ( property_exists( $this, $_key )) { |
|
160 | + $_key = '_'.$key; |
|
161 | + if (property_exists($this, $_key)) { |
|
162 | 162 | $this->{$_key} = $value; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | // ensure that "required" is set correctly |
166 | 166 | $this->set_required( |
167 | - $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) |
|
168 | - ? $input_args[ 'required_validation_error_message' ] |
|
167 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
168 | + ? $input_args['required_validation_error_message'] |
|
169 | 169 | : null |
170 | 170 | ); |
171 | 171 | |
172 | 172 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
173 | 173 | |
174 | 174 | $this->_display_strategy->_construct_finalize($this); |
175 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
175 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
176 | 176 | $validation_strategy->_construct_finalize($this); |
177 | 177 | } |
178 | 178 | |
179 | - if( ! $this->_normalization_strategy){ |
|
179 | + if ( ! $this->_normalization_strategy) { |
|
180 | 180 | $this->_normalization_strategy = new EE_Text_Normalization(); |
181 | 181 | } |
182 | 182 | $this->_normalization_strategy->_construct_finalize($this); |
183 | 183 | |
184 | 184 | //at least we can use the normalization strategy to populate the default |
185 | - if( isset( $input_args[ 'default' ] ) ) { |
|
186 | - $this->set_default( $input_args[ 'default' ] ); |
|
185 | + if (isset($input_args['default'])) { |
|
186 | + $this->set_default($input_args['default']); |
|
187 | 187 | } |
188 | 188 | |
189 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
189 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
190 | 190 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
191 | 191 | } |
192 | 192 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
193 | - parent::__construct( $input_args ); |
|
193 | + parent::__construct($input_args); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @throws \EE_Error |
203 | 203 | */ |
204 | - protected function _set_default_html_name_if_empty(){ |
|
205 | - if( ! $this->_html_name){ |
|
204 | + protected function _set_default_html_name_if_empty() { |
|
205 | + if ( ! $this->_html_name) { |
|
206 | 206 | $this->_html_name = $this->name(); |
207 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
208 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
207 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
208 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | public function _construct_finalize($parent_form_section, $name) { |
221 | 221 | parent::_construct_finalize($parent_form_section, $name); |
222 | 222 | $this->_set_default_html_name_if_empty(); |
223 | - if( ! $this->_html_label && ! $this->_html_label_text){ |
|
224 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
223 | + if ( ! $this->_html_label && ! $this->_html_label_text) { |
|
224 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
225 | 225 | } |
226 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
226 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @return EE_Display_Strategy_Base |
232 | 232 | * @throws EE_Error |
233 | 233 | */ |
234 | - protected function _get_display_strategy(){ |
|
235 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
234 | + protected function _get_display_strategy() { |
|
235 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
236 | 236 | throw new EE_Error( |
237 | 237 | sprintf( |
238 | 238 | __( |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->html_id() |
244 | 244 | ) |
245 | 245 | ); |
246 | - }else{ |
|
246 | + } else { |
|
247 | 247 | return $this->_display_strategy; |
248 | 248 | } |
249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * Sets the display strategy. |
252 | 252 | * @param EE_Display_Strategy_Base $strategy |
253 | 253 | */ |
254 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
254 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
255 | 255 | $this->_display_strategy = $strategy; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * Sets the sanitization strategy |
260 | 260 | * @param EE_Normalization_Strategy_Base $strategy |
261 | 261 | */ |
262 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
262 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
263 | 263 | $this->_normalization_strategy = $strategy; |
264 | 264 | } |
265 | 265 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | * Gets the display strategy for this input |
286 | 286 | * @return EE_Display_Strategy_Base |
287 | 287 | */ |
288 | - public function get_display_strategy(){ |
|
288 | + public function get_display_strategy() { |
|
289 | 289 | return $this->_display_strategy; |
290 | 290 | } |
291 | 291 | /** |
292 | 292 | * Overwrites the display strategy |
293 | 293 | * @param EE_Display_Strategy_Base $display_strategy |
294 | 294 | */ |
295 | - public function set_display_strategy($display_strategy){ |
|
295 | + public function set_display_strategy($display_strategy) { |
|
296 | 296 | $this->_display_strategy = $display_strategy; |
297 | 297 | $this->_display_strategy->_construct_finalize($this); |
298 | 298 | } |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | * Gets the normalization strategy set on this input |
301 | 301 | * @return EE_Normalization_Strategy_Base |
302 | 302 | */ |
303 | - public function get_normalization_strategy(){ |
|
303 | + public function get_normalization_strategy() { |
|
304 | 304 | return $this->_normalization_strategy; |
305 | 305 | } |
306 | 306 | /** |
307 | 307 | * Overwrites the normalization strategy |
308 | 308 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
309 | 309 | */ |
310 | - public function set_normalization_strategy($normalization_strategy){ |
|
310 | + public function set_normalization_strategy($normalization_strategy) { |
|
311 | 311 | $this->_normalization_strategy = $normalization_strategy; |
312 | 312 | $this->_normalization_strategy->_construct_finalize($this); |
313 | 313 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * Returns all teh validation strategies which apply to this field, numerically indexed |
317 | 317 | * @return EE_Validation_Strategy_Base[] |
318 | 318 | */ |
319 | - public function get_validation_strategies(){ |
|
319 | + public function get_validation_strategies() { |
|
320 | 320 | return $this->_validation_strategies; |
321 | 321 | } |
322 | 322 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
331 | - $validation_strategy->_construct_finalize( $this ); |
|
330 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
331 | + $validation_strategy->_construct_finalize($this); |
|
332 | 332 | $this->_validation_strategies[] = $validation_strategy; |
333 | 333 | } |
334 | 334 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_Validation_Strategy_Base $validation_strategy |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
343 | - $this->_add_validation_strategy( $validation_strategy ); |
|
342 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
343 | + $this->_add_validation_strategy($validation_strategy); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @param string $validation_strategy_classname |
352 | 352 | */ |
353 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
354 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
355 | - if( |
|
353 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
354 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
355 | + if ( |
|
356 | 356 | $validation_strategy instanceof $validation_strategy_classname |
357 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
357 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
358 | 358 | ) { |
359 | - unset( $this->_validation_strategies[ $key ] ); |
|
359 | + unset($this->_validation_strategies[$key]); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * @param array $validation_strategy_classnames |
370 | 370 | * @return bool |
371 | 371 | */ |
372 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
373 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
372 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
373 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
374 | 374 | ? $validation_strategy_classnames |
375 | - : array( $validation_strategy_classnames ); |
|
376 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
377 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
375 | + : array($validation_strategy_classnames); |
|
376 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
377 | + if (in_array($key, $validation_strategy_classnames)) { |
|
378 | 378 | return true; |
379 | 379 | } |
380 | 380 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * Gets the HTML |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_html(){ |
|
390 | + public function get_html() { |
|
391 | 391 | return $this->_parent_section->get_html_for_input($this); |
392 | 392 | } |
393 | 393 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return string |
402 | 402 | * @throws \EE_Error |
403 | 403 | */ |
404 | - public function get_html_for_input(){ |
|
404 | + public function get_html_for_input() { |
|
405 | 405 | return $this->_get_display_strategy()->display(); |
406 | 406 | } |
407 | 407 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @return string |
412 | 412 | */ |
413 | 413 | public function html_other_attributes() { |
414 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
414 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | /** |
420 | 420 | * @param string $html_other_attributes |
421 | 421 | */ |
422 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
422 | + public function set_html_other_attributes($html_other_attributes) { |
|
423 | 423 | $this->_html_other_attributes = $html_other_attributes; |
424 | 424 | } |
425 | 425 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * according to the form section's layout strategy |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public function get_html_for_label(){ |
|
431 | + public function get_html_for_label() { |
|
432 | 432 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
433 | 433 | } |
434 | 434 | /** |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * according to the form section's layout strategy |
437 | 437 | * @return string |
438 | 438 | */ |
439 | - public function get_html_for_errors(){ |
|
439 | + public function get_html_for_errors() { |
|
440 | 440 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
441 | 441 | } |
442 | 442 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * according to the form section's layout strategy |
445 | 445 | * @return string |
446 | 446 | */ |
447 | - public function get_html_for_help(){ |
|
447 | + public function get_html_for_help() { |
|
448 | 448 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
449 | 449 | } |
450 | 450 | /** |
@@ -453,18 +453,18 @@ discard block |
||
453 | 453 | * @return boolean |
454 | 454 | */ |
455 | 455 | protected function _validate() { |
456 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
457 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
458 | - try{ |
|
456 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
457 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
458 | + try { |
|
459 | 459 | $validation_strategy->validate($this->normalized_value()); |
460 | - }catch(EE_Validation_Error $e){ |
|
460 | + } catch (EE_Validation_Error $e) { |
|
461 | 461 | $this->add_validation_error($e); |
462 | 462 | } |
463 | 463 | } |
464 | 464 | } |
465 | - if( $this->get_validation_errors()){ |
|
465 | + if ($this->get_validation_errors()) { |
|
466 | 466 | return false; |
467 | - }else{ |
|
467 | + } else { |
|
468 | 468 | return true; |
469 | 469 | } |
470 | 470 | } |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * @param string $value |
479 | 479 | * @return null|string |
480 | 480 | */ |
481 | - private function _sanitize( $value ) { |
|
482 | - return $value !== null ? stripslashes( html_entity_decode( trim( $value ) ) ) : null; |
|
481 | + private function _sanitize($value) { |
|
482 | + return $value !== null ? stripslashes(html_entity_decode(trim($value))) : null; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -493,24 +493,24 @@ discard block |
||
493 | 493 | * @return boolean whether or not there was an error |
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | - protected function _normalize( $req_data ) { |
|
496 | + protected function _normalize($req_data) { |
|
497 | 497 | //any existing validation errors don't apply so clear them |
498 | 498 | $this->_validation_errors = array(); |
499 | 499 | try { |
500 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
500 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
501 | 501 | //super simple sanitization for now |
502 | - if ( is_array( $raw_input )) { |
|
502 | + if (is_array($raw_input)) { |
|
503 | 503 | $this->_raw_value = array(); |
504 | - foreach( $raw_input as $key => $value ) { |
|
505 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
504 | + foreach ($raw_input as $key => $value) { |
|
505 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
506 | 506 | } |
507 | 507 | } else { |
508 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
508 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
509 | 509 | } |
510 | 510 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
511 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
512 | - } catch ( EE_Validation_Error $e ) { |
|
513 | - $this->add_validation_error( $e ); |
|
511 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
512 | + } catch (EE_Validation_Error $e) { |
|
513 | + $this->add_validation_error($e); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @return string |
521 | 521 | */ |
522 | - public function html_name(){ |
|
522 | + public function html_name() { |
|
523 | 523 | return $this->_html_name; |
524 | 524 | } |
525 | 525 | |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | /** |
529 | 529 | * @return string |
530 | 530 | */ |
531 | - public function html_label_id(){ |
|
532 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
531 | + public function html_label_id() { |
|
532 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | /** |
538 | 538 | * @return string |
539 | 539 | */ |
540 | - public function html_label_class(){ |
|
540 | + public function html_label_class() { |
|
541 | 541 | return $this->_html_label_class; |
542 | 542 | } |
543 | 543 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | /** |
547 | 547 | * @return string |
548 | 548 | */ |
549 | - public function html_label_style(){ |
|
549 | + public function html_label_style() { |
|
550 | 550 | return $this->_html_label_style; |
551 | 551 | } |
552 | 552 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | /** |
556 | 556 | * @return string |
557 | 557 | */ |
558 | - public function html_label_text(){ |
|
558 | + public function html_label_text() { |
|
559 | 559 | return $this->_html_label_text; |
560 | 560 | } |
561 | 561 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | /** |
565 | 565 | * @return string |
566 | 566 | */ |
567 | - public function html_help_text(){ |
|
567 | + public function html_help_text() { |
|
568 | 568 | return $this->_html_help_text; |
569 | 569 | } |
570 | 570 | |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | /** |
574 | 574 | * @return string |
575 | 575 | */ |
576 | - public function html_help_class(){ |
|
576 | + public function html_help_class() { |
|
577 | 577 | return $this->_html_help_class; |
578 | 578 | } |
579 | 579 | |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | /** |
583 | 583 | * @return string |
584 | 584 | */ |
585 | - public function html_help_style(){ |
|
585 | + public function html_help_style() { |
|
586 | 586 | return $this->_html_style; |
587 | 587 | } |
588 | 588 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * in which case, we would have stored the malicious content to our database. |
596 | 596 | * @return string |
597 | 597 | */ |
598 | - public function raw_value(){ |
|
598 | + public function raw_value() { |
|
599 | 599 | return $this->_raw_value; |
600 | 600 | } |
601 | 601 | /** |
@@ -603,15 +603,15 @@ discard block |
||
603 | 603 | * it escapes all html entities |
604 | 604 | * @return string |
605 | 605 | */ |
606 | - public function raw_value_in_form(){ |
|
607 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
606 | + public function raw_value_in_form() { |
|
607 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
608 | 608 | } |
609 | 609 | /** |
610 | 610 | * returns the value after it's been sanitized, and then converted into it's proper type |
611 | 611 | * in PHP. Eg, a string, an int, an array, |
612 | 612 | * @return mixed |
613 | 613 | */ |
614 | - public function normalized_value(){ |
|
614 | + public function normalized_value() { |
|
615 | 615 | return $this->_normalized_value; |
616 | 616 | } |
617 | 617 | |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * the best thing to display |
622 | 622 | * @return string |
623 | 623 | */ |
624 | - public function pretty_value(){ |
|
624 | + public function pretty_value() { |
|
625 | 625 | return $this->_normalized_value; |
626 | 626 | } |
627 | 627 | /** |
@@ -640,19 +640,19 @@ discard block |
||
640 | 640 | }</code> |
641 | 641 | * @return array |
642 | 642 | */ |
643 | - public function get_jquery_validation_rules(){ |
|
643 | + public function get_jquery_validation_rules() { |
|
644 | 644 | $jquery_validation_js = array(); |
645 | 645 | $jquery_validation_rules = array(); |
646 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
646 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
647 | 647 | $jquery_validation_rules = array_replace_recursive( |
648 | 648 | $jquery_validation_rules, |
649 | 649 | $validation_strategy->get_jquery_validation_rule_array() |
650 | 650 | ); |
651 | 651 | } |
652 | 652 | |
653 | - if(! empty($jquery_validation_rules)){ |
|
654 | - foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) { |
|
655 | - $jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules; |
|
653 | + if ( ! empty($jquery_validation_rules)) { |
|
654 | + foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) { |
|
655 | + $jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules; |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | return $jquery_validation_js; |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | * @param mixed $value |
665 | 665 | * @return void |
666 | 666 | */ |
667 | - public function set_default($value){ |
|
667 | + public function set_default($value) { |
|
668 | 668 | $this->_normalized_value = $value; |
669 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
669 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | * @param string $label |
675 | 675 | * @return void |
676 | 676 | */ |
677 | - public function set_html_label_text($label){ |
|
677 | + public function set_html_label_text($label) { |
|
678 | 678 | $this->_html_label_text = $label; |
679 | 679 | } |
680 | 680 | |
@@ -688,13 +688,13 @@ discard block |
||
688 | 688 | * @param boolean $required boolean |
689 | 689 | * @param null $required_text |
690 | 690 | */ |
691 | - public function set_required($required = true, $required_text = NULL ){ |
|
692 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
691 | + public function set_required($required = true, $required_text = NULL) { |
|
692 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
693 | 693 | //whether $required is a string or a boolean, we want to add a required validation strategy |
694 | - if ( $required ) { |
|
695 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
694 | + if ($required) { |
|
695 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
696 | 696 | } else { |
697 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
697 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
698 | 698 | } |
699 | 699 | $this->_required = $required; |
700 | 700 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * Returns whether or not this field is required |
703 | 703 | * @return boolean |
704 | 704 | */ |
705 | - public function required(){ |
|
705 | + public function required() { |
|
706 | 706 | return $this->_required; |
707 | 707 | } |
708 | 708 | |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | /** |
712 | 712 | * @param string $required_css_class |
713 | 713 | */ |
714 | - public function set_required_css_class( $required_css_class ) { |
|
714 | + public function set_required_css_class($required_css_class) { |
|
715 | 715 | $this->_required_css_class = $required_css_class; |
716 | 716 | } |
717 | 717 | |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * Sets the help text, in case |
731 | 731 | * @param string $text |
732 | 732 | */ |
733 | - public function set_html_help_text($text){ |
|
733 | + public function set_html_help_text($text) { |
|
734 | 734 | $this->_html_help_text = $text; |
735 | 735 | } |
736 | 736 | /** |
@@ -742,8 +742,8 @@ discard block |
||
742 | 742 | public function clean_sensitive_data() { |
743 | 743 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
744 | 744 | //if we need more logic than this we'll make a strategy for it |
745 | - if( $this->_sensitive_data_removal_strategy && |
|
746 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
745 | + if ($this->_sensitive_data_removal_strategy && |
|
746 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
747 | 747 | $this->_raw_value = NULL; |
748 | 748 | } |
749 | 749 | //and clean the normalized value according to the appropriate strategy |
@@ -759,10 +759,10 @@ discard block |
||
759 | 759 | * @param string $button_size |
760 | 760 | * @param string $other_attributes |
761 | 761 | */ |
762 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
762 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
763 | 763 | $button_css_attributes = 'button'; |
764 | 764 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
765 | - switch ( $button_size ) { |
|
765 | + switch ($button_size) { |
|
766 | 766 | case 'xs' : |
767 | 767 | case 'extra-small' : |
768 | 768 | $button_css_attributes .= ' button-xs'; |
@@ -783,8 +783,8 @@ discard block |
||
783 | 783 | default : |
784 | 784 | $button_css_attributes .= ''; |
785 | 785 | } |
786 | - $this->_button_css_attributes .= ! empty( $other_attributes ) |
|
787 | - ? $button_css_attributes . ' ' . $other_attributes |
|
786 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
787 | + ? $button_css_attributes.' '.$other_attributes |
|
788 | 788 | : $button_css_attributes; |
789 | 789 | } |
790 | 790 | |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * @return string |
795 | 795 | */ |
796 | 796 | public function button_css_attributes() { |
797 | - if ( empty( $this->_button_css_attributes )) { |
|
797 | + if (empty($this->_button_css_attributes)) { |
|
798 | 798 | $this->set_button_css_attributes(); |
799 | 799 | } |
800 | 800 | return $this->_button_css_attributes; |
@@ -816,26 +816,26 @@ discard block |
||
816 | 816 | * @return mixed whatever the raw value of this form section is in the request data |
817 | 817 | * @throws \EE_Error |
818 | 818 | */ |
819 | - public function find_form_data_for_this_section( $req_data ){ |
|
819 | + public function find_form_data_for_this_section($req_data) { |
|
820 | 820 | // break up the html name by "[]" |
821 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
822 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
821 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
822 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
823 | 823 | } else { |
824 | 824 | $before_any_brackets = $this->html_name(); |
825 | 825 | } |
826 | 826 | // grab all of the segments |
827 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
828 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
829 | - $name_parts = $matches[ 1 ]; |
|
827 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
828 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
829 | + $name_parts = $matches[1]; |
|
830 | 830 | array_unshift($name_parts, $before_any_brackets); |
831 | - }else{ |
|
832 | - $name_parts = array( $before_any_brackets ); |
|
831 | + } else { |
|
832 | + $name_parts = array($before_any_brackets); |
|
833 | 833 | } |
834 | 834 | // now get the value for the input |
835 | 835 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
836 | 836 | // check if this thing's name is at the TOP level of the request data |
837 | - if( $value === null && isset( $req_data[ $this->name() ] ) ){ |
|
838 | - $value = $req_data[ $this->name() ]; |
|
837 | + if ($value === null && isset($req_data[$this->name()])) { |
|
838 | + $value = $req_data[$this->name()]; |
|
839 | 839 | } |
840 | 840 | return $value; |
841 | 841 | } |
@@ -848,18 +848,18 @@ discard block |
||
848 | 848 | * @param array $req_data |
849 | 849 | * @return array | NULL |
850 | 850 | */ |
851 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
852 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
853 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
854 | - if( empty($html_name_parts ) ){ |
|
855 | - return $req_data[ $first_part_to_consider ]; |
|
856 | - }else{ |
|
851 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
852 | + $first_part_to_consider = array_shift($html_name_parts); |
|
853 | + if (isset($req_data[$first_part_to_consider])) { |
|
854 | + if (empty($html_name_parts)) { |
|
855 | + return $req_data[$first_part_to_consider]; |
|
856 | + } else { |
|
857 | 857 | return $this->_find_form_data_for_this_section_using_name_parts( |
858 | 858 | $html_name_parts, |
859 | - $req_data[ $first_part_to_consider ] |
|
859 | + $req_data[$first_part_to_consider] |
|
860 | 860 | ); |
861 | 861 | } |
862 | - }else{ |
|
862 | + } else { |
|
863 | 863 | return NULL; |
864 | 864 | } |
865 | 865 | } |
@@ -873,14 +873,14 @@ discard block |
||
873 | 873 | * @return boolean |
874 | 874 | * @throws \EE_Error |
875 | 875 | */ |
876 | - public function form_data_present_in($req_data = NULL){ |
|
877 | - if( $req_data === NULL ){ |
|
876 | + public function form_data_present_in($req_data = NULL) { |
|
877 | + if ($req_data === NULL) { |
|
878 | 878 | $req_data = $_POST; |
879 | 879 | } |
880 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
881 | - if( $checked_value !== null ){ |
|
880 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
881 | + if ($checked_value !== null) { |
|
882 | 882 | return TRUE; |
883 | - }else{ |
|
883 | + } else { |
|
884 | 884 | return FALSE; |
885 | 885 | } |
886 | 886 | } |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | * @param array $form_other_js_data |
892 | 892 | * @return array |
893 | 893 | */ |
894 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
895 | - $form_other_js_data = $this->get_other_js_data_from_strategies( $form_other_js_data ); |
|
894 | + public function get_other_js_data($form_other_js_data = array()) { |
|
895 | + $form_other_js_data = $this->get_other_js_data_from_strategies($form_other_js_data); |
|
896 | 896 | return $form_other_js_data; |
897 | 897 | } |
898 | 898 | |
@@ -905,10 +905,10 @@ discard block |
||
905 | 905 | * @param array $form_other_js_data |
906 | 906 | * @return array |
907 | 907 | */ |
908 | - public function get_other_js_data_from_strategies( $form_other_js_data = array() ) { |
|
909 | - $form_other_js_data = $this->get_display_strategy()->get_other_js_data( $form_other_js_data ); |
|
910 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
911 | - $form_other_js_data = $validation_strategy->get_other_js_data( $form_other_js_data ); |
|
908 | + public function get_other_js_data_from_strategies($form_other_js_data = array()) { |
|
909 | + $form_other_js_data = $this->get_display_strategy()->get_other_js_data($form_other_js_data); |
|
910 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
911 | + $form_other_js_data = $validation_strategy->get_other_js_data($form_other_js_data); |
|
912 | 912 | } |
913 | 913 | return $form_other_js_data; |
914 | 914 | } |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | * Override parent because we want to give our strategies an opportunity to enqueue some js and css |
918 | 918 | * @return void |
919 | 919 | */ |
920 | - public function enqueue_js(){ |
|
920 | + public function enqueue_js() { |
|
921 | 921 | //ask our display strategy and validation strategies if they have js to enqueue |
922 | 922 | $this->enqueue_js_from_strategies(); |
923 | 923 | } |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | */ |
929 | 929 | public function enqueue_js_from_strategies() { |
930 | 930 | $this->get_display_strategy()->enqueue_js(); |
931 | - foreach( $this->get_validation_strategies() as $validation_strategy ) { |
|
931 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
932 | 932 | $validation_strategy->enqueue_js(); |
933 | 933 | } |
934 | 934 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | $this->description = __('All shortcodes related to emails', 'event_espresso'); |
44 | 44 | $this->_shortcodes = array( |
45 | 45 | '[SITE_ADMIN_EMAIL]' => __('Will be replaced with the admin email for the site that Event Espresso is installed on', 'event_espresso'), |
46 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' => __('This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', 'event_espresso'),'<strong>','</strong>', |
|
46 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' => __('This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', 'event_espresso'), '<strong>', '</strong>', |
|
47 | 47 | '[EVENT_AUTHOR_EMAIL]' => __('This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', 'event_espresso'), '[EVENT_AUTHOR_FORMATTED_EMAIL]', |
48 | - '[CO_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso' ), |
|
48 | + '[CO_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso'), |
|
49 | 49 | '[CO_EMAIL]' => __('This will parse to the email address only for the organization set in Your Organization Settings.', 'event_espresso'), |
50 | - '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso' ), |
|
50 | + '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => __('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso'), |
|
51 | 51 | '[ESPRESSO_ADMIN_EMAIL]' => __('This parses to the email address only for the organization set in Your Organization Settings page.', 'event_espresso') |
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | - protected function _parser( $shortcode ) { |
|
56 | + protected function _parser($shortcode) { |
|
57 | 57 | |
58 | - switch ( $shortcode ) { |
|
58 | + switch ($shortcode) { |
|
59 | 59 | |
60 | 60 | case '[SITE_ADMIN_EMAIL]' : |
61 | 61 | return $this->_get_site_admin_email(); |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | break; |
67 | 67 | |
68 | 68 | case '[EVENT_AUTHOR_EMAIL]' : |
69 | - return $this->_get_event_admin_emails( FALSE ); |
|
69 | + return $this->_get_event_admin_emails(FALSE); |
|
70 | 70 | break; |
71 | 71 | |
72 | 72 | case '[CO_FORMATTED_EMAIL]' : |
73 | 73 | case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' : |
74 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) . '>'; |
|
74 | + return EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.EE_Registry::instance()->CFG->organization->get_pretty('email').'>'; |
|
75 | 75 | break; |
76 | 76 | |
77 | 77 | case '[CO_EMAIL]' : |
78 | 78 | case '[ESPRESSO_ADMIN_EMAIL]' : |
79 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
79 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | default : |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | - private function _get_event_admin_emails( $fancy_headers = TRUE ) { |
|
101 | + private function _get_event_admin_emails($fancy_headers = TRUE) { |
|
102 | 102 | |
103 | - if ( !empty( $this->_data->admin_email ) ) { |
|
104 | - if ( ! $fancy_headers ) |
|
103 | + if ( ! empty($this->_data->admin_email)) { |
|
104 | + if ( ! $fancy_headers) |
|
105 | 105 | return $this->_data->admin_email; |
106 | - return !empty( $this->_data->fname ) ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' : EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . $this->_data->admin_email . '>'; |
|
106 | + return ! empty($this->_data->fname) ? $this->_data->fname.' '.$this->_data->lname.' <'.$this->_data->admin_email.'>' : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$this->_data->admin_email.'>'; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | //k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | $admin_email = array(); |
112 | 112 | |
113 | 113 | //loop through events and set the list of event_ids to retrieve so we can do ONE query. |
114 | - foreach ( $this->_data->events as $event ) { |
|
114 | + foreach ($this->_data->events as $event) { |
|
115 | 115 | $ids[] = $event['ID']; |
116 | 116 | } |
117 | 117 | |
118 | 118 | //get all the events |
119 | - $events = EE_Registry::instance()->load_model('Event')->get_all( array(array('EVT_ID' => array('IN', $ids ) ) ) ); |
|
119 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids)))); |
|
120 | 120 | |
121 | 121 | //now loop through each event and setup the details |
122 | 122 | $admin_details = array(); |
123 | 123 | $cnt = 0; |
124 | - foreach ( $events as $event ) { |
|
125 | - $user = get_userdata($event->get('EVT_wp_user') ); |
|
124 | + foreach ($events as $event) { |
|
125 | + $user = get_userdata($event->get('EVT_wp_user')); |
|
126 | 126 | $admin_details[$cnt] = new stdClass(); |
127 | 127 | $admin_details[$cnt]->email = $user->user_email; |
128 | 128 | $admin_details[$cnt]->first_name = $user->user_firstname; |
@@ -131,28 +131,28 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | //results? |
134 | - if ( empty($admin_details) || !is_array($admin_details) ) { |
|
134 | + if (empty($admin_details) || ! is_array($admin_details)) { |
|
135 | 135 | $msg[] = __('The admin details could not be retrieved from the database.', 'event_espresso'); |
136 | - $msg[] = sprintf( __('Query: %s', 'event_espresso'), $sql ); |
|
137 | - $msg[] = sprintf( __('Events Data: %s', 'event_espresso'), var_export($this->_data->events, TRUE) ); |
|
138 | - $msg[] = sprintf( __('Event IDS: %s', 'event_espresso'), var_export($ids, TRUE) ); |
|
139 | - $msg[] = sprintf( __('Query Results: %s', 'event_espresso'), var_export($admin_details) ); |
|
140 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, implode( PHP_EOL, $msg ), 'shortcode_parser' ); |
|
136 | + $msg[] = sprintf(__('Query: %s', 'event_espresso'), $sql); |
|
137 | + $msg[] = sprintf(__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, TRUE)); |
|
138 | + $msg[] = sprintf(__('Event IDS: %s', 'event_espresso'), var_export($ids, TRUE)); |
|
139 | + $msg[] = sprintf(__('Query Results: %s', 'event_espresso'), var_export($admin_details)); |
|
140 | + do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser'); |
|
141 | 141 | } |
142 | 142 | |
143 | - foreach ( $admin_details as $admin ) { |
|
143 | + foreach ($admin_details as $admin) { |
|
144 | 144 | //only add an admin email if it is present. |
145 | - if ( empty( $admin->email ) || $admin->email == '' ) continue; |
|
145 | + if (empty($admin->email) || $admin->email == '') continue; |
|
146 | 146 | |
147 | - if ( ! $fancy_headers ) { |
|
147 | + if ( ! $fancy_headers) { |
|
148 | 148 | $admin_email[] = $admin->email; |
149 | 149 | continue; |
150 | 150 | } |
151 | 151 | |
152 | - $admin_email[] = !empty( $admin->first_name ) ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' : EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . $admin->email . '>'; |
|
152 | + $admin_email[] = ! empty($admin->first_name) ? $admin->first_name.' '.$admin->last_name.' <'.$admin->email.'>' : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$admin->email.'>'; |
|
153 | 153 | } |
154 | 154 | |
155 | - $admin_email = implode( ',', $admin_email ); |
|
155 | + $admin_email = implode(',', $admin_email); |
|
156 | 156 | return $admin_email; |
157 | 157 | } |
158 | 158 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -58,96 +58,96 @@ discard block |
||
58 | 58 | '[CO_GOOGLE_URL]' => __('Link to organization Google page', 'event_espresso'), |
59 | 59 | '[CO_LINKEDIN_URL]' => __('Link to organization LinkedIn page', 'event_espresso'), |
60 | 60 | '[CO_INSTAGRAM_URL]' => __('Link to organization Instagram page', 'event_espresso'), |
61 | - '[CO_TAX_NUMBER_*]' => __('This is the shortcode used for displaying any tax number for the company. %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56. Also take note that if you have NO number in your settings, the prefix is not output either.', 'event_espresso','<strong>','</strong>') |
|
61 | + '[CO_TAX_NUMBER_*]' => __('This is the shortcode used for displaying any tax number for the company. %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56. Also take note that if you have NO number in your settings, the prefix is not output either.', 'event_espresso', '<strong>', '</strong>') |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
65 | 65 | |
66 | - protected function _parser( $shortcode ) { |
|
66 | + protected function _parser($shortcode) { |
|
67 | 67 | |
68 | - switch ( $shortcode ) { |
|
68 | + switch ($shortcode) { |
|
69 | 69 | |
70 | 70 | case '[COMPANY]' : |
71 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
71 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
72 | 72 | break; |
73 | 73 | |
74 | 74 | case '[CO_ADD1]' : |
75 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'address_1' ); |
|
75 | + return EE_Registry::instance()->CFG->organization->get_pretty('address_1'); |
|
76 | 76 | break; |
77 | 77 | |
78 | 78 | case '[CO_ADD2]' : |
79 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'address_2' ); |
|
79 | + return EE_Registry::instance()->CFG->organization->get_pretty('address_2'); |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | case '[CO_CITY]' : |
83 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'city' ); |
|
83 | + return EE_Registry::instance()->CFG->organization->get_pretty('city'); |
|
84 | 84 | break; |
85 | 85 | |
86 | 86 | case '[CO_STATE]' : |
87 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( EE_Registry::instance()->CFG->organization->STA_ID ); |
|
87 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID(EE_Registry::instance()->CFG->organization->STA_ID); |
|
88 | 88 | return $state->name(); |
89 | 89 | break; |
90 | 90 | |
91 | 91 | case '[CO_ZIP]' : |
92 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'zip' ); |
|
92 | + return EE_Registry::instance()->CFG->organization->get_pretty('zip'); |
|
93 | 93 | break; |
94 | 94 | |
95 | 95 | case '[CO_EMAIL]' : |
96 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
96 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
97 | 97 | break; |
98 | 98 | |
99 | 99 | case '[CO_PHONE]' : |
100 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'phone' ); |
|
100 | + return EE_Registry::instance()->CFG->organization->get_pretty('phone'); |
|
101 | 101 | break; |
102 | 102 | |
103 | 103 | case '[CO_LOGO]' : |
104 | - return '<img src="' . EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ) . '" id="headerImage" />'; |
|
104 | + return '<img src="'.EE_Registry::instance()->CFG->organization->get_pretty('logo_url').'" id="headerImage" />'; |
|
105 | 105 | break; |
106 | 106 | |
107 | 107 | case '[CO_LOGO_URL]' : |
108 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
108 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
109 | 109 | break; |
110 | 110 | |
111 | 111 | case '[CO_FACEBOOK_URL]' : |
112 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
112 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
113 | 113 | break; |
114 | 114 | |
115 | 115 | case '[CO_TWITTER_URL]' : |
116 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
116 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
117 | 117 | break; |
118 | 118 | |
119 | 119 | case '[CO_PINTEREST_URL]' : |
120 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
120 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
121 | 121 | break; |
122 | 122 | |
123 | 123 | case '[CO_LINKEDIN_URL]' : |
124 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
124 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
125 | 125 | break; |
126 | 126 | |
127 | 127 | case '[CO_GOOGLE_URL]' : |
128 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
128 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | case '[CO_INSTAGRAM_URL]' : |
132 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
132 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
133 | 133 | break; |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | 137 | //also allow for parameter shortcode |
138 | - if ( strpos( $shortcode, '[CO_TAX_NUMBER_*' ) !== FALSE ) { |
|
138 | + if (strpos($shortcode, '[CO_TAX_NUMBER_*') !== FALSE) { |
|
139 | 139 | //first see if there is any company tax number set and bail early if not |
140 | 140 | $tax_number = EE_Registry::instance()->CFG->organization->vat; |
141 | - if ( empty( $tax_number ) ) { |
|
141 | + if (empty($tax_number)) { |
|
142 | 142 | return ''; |
143 | 143 | } |
144 | 144 | |
145 | 145 | //see if there are any attributes. |
146 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
146 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
147 | 147 | |
148 | 148 | //set custom attrs if present (or default) |
149 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso'); |
|
150 | - return $prefix . $tax_number; |
|
149 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso'); |
|
150 | + return $prefix.$tax_number; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return ''; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
159 | 159 | )); |
160 | 160 | */ |
161 | -class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage{ |
|
161 | +class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage { |
|
162 | 162 | private $_old_table; |
163 | 163 | private $_old_start_end_table; |
164 | 164 | private $_new_table; |
@@ -184,41 +184,41 @@ discard block |
||
184 | 184 | protected function _migration_step($num_items_to_migrate = 50) { |
185 | 185 | global $wpdb; |
186 | 186 | //because the migration of each event can be a LOT more work, make each step smaller |
187 | - $num_items_to_migrate = max(1,$num_items_to_migrate/5); |
|
188 | - $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d",$this->count_records_migrated(),$num_items_to_migrate),ARRAY_A); |
|
187 | + $num_items_to_migrate = max(1, $num_items_to_migrate / 5); |
|
188 | + $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $this->count_records_migrated(), $num_items_to_migrate), ARRAY_A); |
|
189 | 189 | $items_migrated_this_step = 0; |
190 | 190 | |
191 | - foreach($events as $event_row){ |
|
191 | + foreach ($events as $event_row) { |
|
192 | 192 | $created_attachment_post = false; |
193 | 193 | //insert new 4.1 Attendee object using $wpdb |
194 | 194 | $post_id = $this->_insert_cpt($event_row); |
195 | - if($post_id){ |
|
195 | + if ($post_id) { |
|
196 | 196 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_table, $post_id); |
197 | 197 | $meta_id = $this->_insert_event_meta($event_row, $post_id); |
198 | - if($meta_id){ |
|
198 | + if ($meta_id) { |
|
199 | 199 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_meta_table, $meta_id); |
200 | 200 | } |
201 | - $this->_convert_start_end_times($event_row,$post_id); |
|
201 | + $this->_convert_start_end_times($event_row, $post_id); |
|
202 | 202 | $event_meta = maybe_unserialize($event_row['event_meta']); |
203 | 203 | $guid = isset($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : null; |
204 | - $created_attachment_post = $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid,$post_id,$this); |
|
204 | + $created_attachment_post = $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $post_id, $this); |
|
205 | 205 | |
206 | 206 | //maybe create a venue from info on the event? |
207 | 207 | $new_venue_id = $this->_maybe_create_venue($event_row); |
208 | - if($new_venue_id){ |
|
209 | - $this->_insert_new_venue_to_event($post_id,$new_venue_id); |
|
208 | + if ($new_venue_id) { |
|
209 | + $this->_insert_new_venue_to_event($post_id, $new_venue_id); |
|
210 | 210 | } |
211 | 211 | $this->_add_post_metas($event_row, $post_id); |
212 | 212 | |
213 | 213 | } |
214 | 214 | $items_migrated_this_step++; |
215 | - if($guid){ |
|
215 | + if ($guid) { |
|
216 | 216 | //if we had to check for an image attachment |
217 | 217 | //then let's call it a day (avoid timing out, because this took a long time) |
218 | 218 | break; |
219 | 219 | } |
220 | 220 | } |
221 | - if($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()){ |
|
221 | + if ($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()) { |
|
222 | 222 | $this->set_status(EE_Data_Migration_Manager::status_completed); |
223 | 223 | } |
224 | 224 | return $items_migrated_this_step; |
@@ -230,28 +230,28 @@ discard block |
||
230 | 230 | * @param type $post_id |
231 | 231 | * @return void |
232 | 232 | */ |
233 | - private function _add_post_metas($old_event,$post_id){ |
|
233 | + private function _add_post_metas($old_event, $post_id) { |
|
234 | 234 | $event_meta = maybe_unserialize($old_event['event_meta']); |
235 | - if( ! $event_meta || ! is_array( $event_meta ) ){ |
|
235 | + if ( ! $event_meta || ! is_array($event_meta)) { |
|
236 | 236 | return; |
237 | 237 | } |
238 | - unset($event_meta['date_submitted']);//factored into CPT |
|
239 | - unset($event_meta['additional_attendee_reg_info']);//facotred into event meta table |
|
240 | - unset($event_meta['default_payment_status']);//dido |
|
241 | - unset($event_meta['event_thumbnail_url']);//used to find post featured image |
|
242 | - foreach($event_meta as $meta_key => $meta_value){ |
|
243 | - if ($meta_key){//if th emeta key is just an empty string, ignore it |
|
244 | - $success = add_post_meta($post_id,$meta_key,$meta_value,true); |
|
245 | - if( ! $success ){ |
|
246 | - $this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"),$post_id,$meta_key,$meta_value,implode(",",$old_event))); |
|
238 | + unset($event_meta['date_submitted']); //factored into CPT |
|
239 | + unset($event_meta['additional_attendee_reg_info']); //facotred into event meta table |
|
240 | + unset($event_meta['default_payment_status']); //dido |
|
241 | + unset($event_meta['event_thumbnail_url']); //used to find post featured image |
|
242 | + foreach ($event_meta as $meta_key => $meta_value) { |
|
243 | + if ($meta_key) {//if th emeta key is just an empty string, ignore it |
|
244 | + $success = add_post_meta($post_id, $meta_key, $meta_value, true); |
|
245 | + if ( ! $success) { |
|
246 | + $this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"), $post_id, $meta_key, $meta_value, implode(",", $old_event))); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | - if($old_event['alt_email']){ |
|
251 | - add_post_meta($post_id,'alt_email',$old_event['alt_email']); |
|
250 | + if ($old_event['alt_email']) { |
|
251 | + add_post_meta($post_id, 'alt_email', $old_event['alt_email']); |
|
252 | 252 | } |
253 | - if($old_event['recurrence_id']){ |
|
254 | - add_post_meta($post_id,'recurrence_id',$old_event['recurrence_id']); |
|
253 | + if ($old_event['recurrence_id']) { |
|
254 | + add_post_meta($post_id, 'recurrence_id', $old_event['recurrence_id']); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | /** |
@@ -263,13 +263,13 @@ discard block |
||
263 | 263 | * @param string $new_post_status a post status |
264 | 264 | * @return string |
265 | 265 | */ |
266 | - private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish'){ |
|
266 | + private function _find_unique_slug($event_name, $old_identifier = '', $new_post_status = 'publish') { |
|
267 | 267 | $count = 0; |
268 | 268 | $original_name = $event_name ? sanitize_title($event_name) : $old_identifier; |
269 | - return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0 ); |
|
269 | + return wp_unique_post_slug($original_name, 0, $new_post_status, 'espresso_events', 0); |
|
270 | 270 | } |
271 | 271 | |
272 | - private function _insert_cpt($old_event){ |
|
272 | + private function _insert_cpt($old_event) { |
|
273 | 273 | global $wpdb; |
274 | 274 | //convert 3.1 event status to 4.1 CPT status |
275 | 275 | //for refrence, 3.1 event stati available for setting are: |
@@ -288,55 +288,55 @@ discard block |
||
288 | 288 | // and 3 custom ones: cancelled,postponed,sold_out |
289 | 289 | $status_conversions = array( |
290 | 290 | 'R'=>'draft', |
291 | - 'X'=>'draft',//4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
291 | + 'X'=>'draft', //4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
292 | 292 | 'P'=>'pending', |
293 | - 'IA'=>'draft',//draft and in the past |
|
293 | + 'IA'=>'draft', //draft and in the past |
|
294 | 294 | //IA=inactive in 3.1: events were switched to this when they expired. in 4.1 that's just calculated |
295 | - 'O'=>'publish',//@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing' |
|
295 | + 'O'=>'publish', //@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing' |
|
296 | 296 | 'A'=>'publish', |
297 | - 'S'=>'draft',//@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
297 | + 'S'=>'draft', //@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
298 | 298 | 'D'=>'trash', |
299 | 299 | ); |
300 | 300 | $post_status = $status_conversions[$old_event['event_status']]; |
301 | 301 | //check if we've sold out |
302 | - if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])){ |
|
302 | + if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])) { |
|
303 | 303 | $post_status = 'sold_out'; |
304 | 304 | } |
305 | 305 | // FYI postponed and cancelled don't exist in 3.1 |
306 | 306 | $cols_n_values = array( |
307 | - 'post_title'=>stripslashes($old_event['event_name']),//EVT_name |
|
308 | - 'post_content'=>stripslashes($old_event['event_desc']),//EVT_desc |
|
309 | - 'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status ),//EVT_slug |
|
310 | - 'post_date'=>$old_event['submitted'],//EVT_created NOT |
|
307 | + 'post_title'=>stripslashes($old_event['event_name']), //EVT_name |
|
308 | + 'post_content'=>stripslashes($old_event['event_desc']), //EVT_desc |
|
309 | + 'post_name'=>$this->_find_unique_slug($old_event['event_name'], $old_event['event_identifier'], $post_status), //EVT_slug |
|
310 | + 'post_date'=>$old_event['submitted'], //EVT_created NOT |
|
311 | 311 | 'post_date_gmt'=>get_gmt_from_date($old_event['submitted']), |
312 | - 'post_excerpt'=>'',//EVT_short_desc |
|
313 | - 'post_modified'=>$old_event['submitted'],//EVT_modified |
|
312 | + 'post_excerpt'=>'', //EVT_short_desc |
|
313 | + 'post_modified'=>$old_event['submitted'], //EVT_modified |
|
314 | 314 | 'post_modified_gmt'=>get_gmt_from_date($old_event['submitted']), |
315 | - 'post_author'=>$old_event['wp_user'],//EVT_wp_user |
|
316 | - 'post_parent'=>0,//parent maybe get this from some REM field? |
|
317 | - 'menu_order'=>0,//EVT_order |
|
318 | - 'post_type'=>'espresso_events',//post_type |
|
319 | - 'post_status'=>$post_status,//status |
|
315 | + 'post_author'=>$old_event['wp_user'], //EVT_wp_user |
|
316 | + 'post_parent'=>0, //parent maybe get this from some REM field? |
|
317 | + 'menu_order'=>0, //EVT_order |
|
318 | + 'post_type'=>'espresso_events', //post_type |
|
319 | + 'post_status'=>$post_status, //status |
|
320 | 320 | ); |
321 | 321 | $datatypes = array( |
322 | - '%s',//EVT_name |
|
323 | - '%s',//EVT_desc |
|
324 | - '%s',//EVT_slug |
|
325 | - '%s',//EVT_created |
|
322 | + '%s', //EVT_name |
|
323 | + '%s', //EVT_desc |
|
324 | + '%s', //EVT_slug |
|
325 | + '%s', //EVT_created |
|
326 | 326 | '%s', |
327 | - '%s',//EVT_short_desc |
|
328 | - '%s',//EVT_modified |
|
327 | + '%s', //EVT_short_desc |
|
328 | + '%s', //EVT_modified |
|
329 | 329 | '%s', |
330 | - '%s',//EVT_wp_user |
|
331 | - '%d',//post_parent |
|
332 | - '%d',//EVT_order |
|
333 | - '%s',//post_type |
|
334 | - '%s',//status |
|
330 | + '%s', //EVT_wp_user |
|
331 | + '%d', //post_parent |
|
332 | + '%d', //EVT_order |
|
333 | + '%s', //post_type |
|
334 | + '%s', //status |
|
335 | 335 | ); |
336 | 336 | $success = $wpdb->insert($this->_new_table, |
337 | 337 | $cols_n_values, |
338 | 338 | $datatypes); |
339 | - if( ! $success ){ |
|
339 | + if ( ! $success) { |
|
340 | 340 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_table, $cols_n_values, $datatypes)); |
341 | 341 | return 0; |
342 | 342 | } |
@@ -349,13 +349,13 @@ discard block |
||
349 | 349 | * @param type $event_id |
350 | 350 | * @return int |
351 | 351 | */ |
352 | - public static function count_registrations($event_id){ |
|
352 | + public static function count_registrations($event_id) { |
|
353 | 353 | global $wpdb; |
354 | - $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d",$event_id)); |
|
354 | + $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d", $event_id)); |
|
355 | 355 | return intval($count); |
356 | 356 | } |
357 | 357 | |
358 | - private function _insert_event_meta($old_event,$new_cpt_id){ |
|
358 | + private function _insert_event_meta($old_event, $new_cpt_id) { |
|
359 | 359 | global $wpdb; |
360 | 360 | $event_meta = maybe_unserialize($old_event['event_meta']); |
361 | 361 | // for reference, 3.1 'default_payment_status' are: $default_payment_status = array( |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | //); |
367 | 367 | $default_reg_status = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID(isset($event_meta['default_payment_status']) ? $event_meta['default_payment_status'] : '', intval($old_event['require_pre_approval'])); |
368 | 368 | $cols_n_values = array( |
369 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID_fk |
|
369 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID_fk |
|
370 | 370 | 'EVT_display_desc'=> 'Y' == $old_event['display_desc'], |
371 | - 'EVT_display_ticket_selector'=> 'Y'== $old_event['display_reg_form'], |
|
372 | - 'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this,$old_event,current_time('mysql'),$old_event['timezone_string']),//don't use the old 'visible_on', as it wasnt ever used |
|
371 | + 'EVT_display_ticket_selector'=> 'Y' == $old_event['display_reg_form'], |
|
372 | + 'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this, $old_event, current_time('mysql'), $old_event['timezone_string']), //don't use the old 'visible_on', as it wasnt ever used |
|
373 | 373 | 'EVT_additional_limit'=> $old_event['allow_multiple'] == 'N' ? 1 : $old_event['additional_limit'], |
374 | 374 | 'EVT_default_registration_status' => $default_reg_status, |
375 | 375 | 'EVT_member_only'=>$old_event['member_only'], |
@@ -381,31 +381,31 @@ discard block |
||
381 | 381 | |
382 | 382 | ); |
383 | 383 | $datatypes = array( |
384 | - '%s',//EVT_ID |
|
385 | - '%d',//EVT_display_desc |
|
386 | - '%d',//EVT_display_ticket_selector |
|
387 | - '%s',//EVT_visible_on |
|
388 | - '%d',//EVT_additional_limit |
|
389 | - '%s',//EVT_default_registration_status |
|
390 | - '%d',//EVT_member_only |
|
391 | - '%s',//EVT_phone |
|
392 | - '%d',//EVT_allow_overflow |
|
393 | - '%s',//EVT_timezone_string |
|
394 | - '%s',//EVT_external_URL |
|
395 | - '%d',//EVT_donations |
|
384 | + '%s', //EVT_ID |
|
385 | + '%d', //EVT_display_desc |
|
386 | + '%d', //EVT_display_ticket_selector |
|
387 | + '%s', //EVT_visible_on |
|
388 | + '%d', //EVT_additional_limit |
|
389 | + '%s', //EVT_default_registration_status |
|
390 | + '%d', //EVT_member_only |
|
391 | + '%s', //EVT_phone |
|
392 | + '%d', //EVT_allow_overflow |
|
393 | + '%s', //EVT_timezone_string |
|
394 | + '%s', //EVT_external_URL |
|
395 | + '%d', //EVT_donations |
|
396 | 396 | ); |
397 | 397 | $success = $wpdb->insert($this->_new_meta_table, |
398 | 398 | $cols_n_values, |
399 | 399 | $datatypes); |
400 | - if( ! $success ){ |
|
400 | + if ( ! $success) { |
|
401 | 401 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $cols_n_values, $datatypes)); |
402 | 402 | return 0; |
403 | 403 | } |
404 | 404 | return $wpdb->insert_id; |
405 | 405 | } |
406 | 406 | |
407 | - private function _maybe_create_venue($old_event){ |
|
408 | - if( $old_event['address'] || |
|
407 | + private function _maybe_create_venue($old_event) { |
|
408 | + if ($old_event['address'] || |
|
409 | 409 | $old_event['address2'] || |
410 | 410 | $old_event['city'] || |
411 | 411 | $old_event['state'] || |
@@ -416,21 +416,21 @@ discard block |
||
416 | 416 | $old_event['venue_phone'] || |
417 | 417 | $old_event['virtual_url'] || |
418 | 418 | $old_event['virtual_phone'] |
419 | - ){ |
|
420 | - $old_id = $this->_duplicate_venue_exists( $old_event ); |
|
421 | - if( $old_id ){ |
|
419 | + ) { |
|
420 | + $old_id = $this->_duplicate_venue_exists($old_event); |
|
421 | + if ($old_id) { |
|
422 | 422 | return $old_id; |
423 | 423 | } |
424 | 424 | $new_id = $this->_insert_venue_into_posts($old_event); |
425 | - if( $new_id ){ |
|
425 | + if ($new_id) { |
|
426 | 426 | $this->_insert_venue_into_meta_table($new_id, $old_event); |
427 | - $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
428 | - $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id,$this); |
|
427 | + $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
428 | + $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this); |
|
429 | 429 | } |
430 | 430 | //we don't bother recording the conversion from old events to venues as that |
431 | 431 | //will complicate finding the conversion from old venues to new events |
432 | 432 | return $new_id; |
433 | - }else{ |
|
433 | + } else { |
|
434 | 434 | return 0; |
435 | 435 | } |
436 | 436 | } |
@@ -441,29 +441,29 @@ discard block |
||
441 | 441 | * @param array $old_event |
442 | 442 | * @return int duplicate venue id |
443 | 443 | */ |
444 | - private function _duplicate_venue_exists($old_event){ |
|
444 | + private function _duplicate_venue_exists($old_event) { |
|
445 | 445 | global $wpdb; |
446 | 446 | $conditions = array( |
447 | - 'VNU_address' => $old_event [ 'address' ], |
|
448 | - 'VNU_address2' => $old_event[ 'address2' ], |
|
449 | - 'VNU_city' => $old_event[ 'city' ], |
|
450 | - 'VNU_zip' => $old_event[ 'zip' ], |
|
451 | - 'post_title'=> $this->_get_venue_title_for_event( $old_event ), |
|
452 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
453 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
454 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
455 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
447 | + 'VNU_address' => $old_event ['address'], |
|
448 | + 'VNU_address2' => $old_event['address2'], |
|
449 | + 'VNU_city' => $old_event['city'], |
|
450 | + 'VNU_zip' => $old_event['zip'], |
|
451 | + 'post_title'=> $this->_get_venue_title_for_event($old_event), |
|
452 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
453 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
454 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
455 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
456 | 456 | ); |
457 | 457 | $sql_conditions = array(); |
458 | - foreach($conditions as $column => $value){ |
|
458 | + foreach ($conditions as $column => $value) { |
|
459 | 459 | $sql_conditions [] = "$column = '$value'"; |
460 | 460 | } |
461 | 461 | $query = "SELECT VNU_ID |
462 | 462 | FROM |
463 | 463 | {$wpdb->posts} as p INNER JOIN |
464 | 464 | {$wpdb->prefix}esp_venue_meta as v ON p.ID = v.VNU_ID |
465 | - WHERE " . implode( " AND ",$sql_conditions ) . " LIMIT 1"; |
|
466 | - $id = $wpdb->get_var( $query ); |
|
465 | + WHERE ".implode(" AND ", $sql_conditions)." LIMIT 1"; |
|
466 | + $id = $wpdb->get_var($query); |
|
467 | 467 | return $id; |
468 | 468 | } |
469 | 469 | |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | * @param array $event_data_array keys are events_details columns and valuesa re their values |
473 | 473 | * @return string |
474 | 474 | */ |
475 | - protected function _get_venue_title_for_event( $event_data_array ) { |
|
476 | - return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes( sprintf( __( 'Venue of %s', 'event_espresso' ), $event_data_array['event_name'])); |
|
475 | + protected function _get_venue_title_for_event($event_data_array) { |
|
476 | + return $event_data_array['venue_title'] ? stripslashes($event_data_array['venue_title']) : stripslashes(sprintf(__('Venue of %s', 'event_espresso'), $event_data_array['event_name'])); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
@@ -481,40 +481,40 @@ discard block |
||
481 | 481 | * @param array $old_venue keys are cols, values are col values |
482 | 482 | * @return int |
483 | 483 | */ |
484 | - private function _insert_venue_into_posts($old_event){ |
|
484 | + private function _insert_venue_into_posts($old_event) { |
|
485 | 485 | global $wpdb; |
486 | 486 | $insertion_array = array( |
487 | - 'post_title'=> $this->_get_venue_title_for_event( $old_event ),//VNU_name |
|
488 | - 'post_content'=>'',//VNU_desc |
|
489 | - 'post_name'=> $this->_find_unique_slug( $old_event['venue_title'], sanitize_title( 'venue-of-' . $old_event['event_name'] ) ),//VNU_identifier |
|
490 | - 'post_date'=>current_time('mysql'),//VNU_created |
|
487 | + 'post_title'=> $this->_get_venue_title_for_event($old_event), //VNU_name |
|
488 | + 'post_content'=>'', //VNU_desc |
|
489 | + 'post_name'=> $this->_find_unique_slug($old_event['venue_title'], sanitize_title('venue-of-'.$old_event['event_name'])), //VNU_identifier |
|
490 | + 'post_date'=>current_time('mysql'), //VNU_created |
|
491 | 491 | 'post_date_gmt'=>get_gmt_from_date(current_time('mysql')), |
492 | - 'post_excerpt'=>'',//VNU_short_desc arbitraty only 50 characters |
|
493 | - 'post_modified'=>current_time('mysql'),//VNU_modified |
|
492 | + 'post_excerpt'=>'', //VNU_short_desc arbitraty only 50 characters |
|
493 | + 'post_modified'=>current_time('mysql'), //VNU_modified |
|
494 | 494 | 'post_modified_gmt'=>get_gmt_from_date(current_time('mysql')), |
495 | - 'post_author'=>$old_event['wp_user'],//VNU_wp_user |
|
496 | - 'post_parent'=>0,//parent |
|
497 | - 'menu_order'=>0,//VNU_order |
|
495 | + 'post_author'=>$old_event['wp_user'], //VNU_wp_user |
|
496 | + 'post_parent'=>0, //parent |
|
497 | + 'menu_order'=>0, //VNU_order |
|
498 | 498 | 'post_type'=>'espresso_venues'//post_type |
499 | 499 | ); |
500 | 500 | $datatypes_array = array( |
501 | - '%s',//VNU_name |
|
502 | - '%s',//VNU_desc |
|
503 | - '%s',//VNU_identifier |
|
504 | - '%s',//VNU_created |
|
501 | + '%s', //VNU_name |
|
502 | + '%s', //VNU_desc |
|
503 | + '%s', //VNU_identifier |
|
504 | + '%s', //VNU_created |
|
505 | 505 | '%s', |
506 | - '%s',//VNU_short_desc |
|
507 | - '%s',//VNU_modified |
|
506 | + '%s', //VNU_short_desc |
|
507 | + '%s', //VNU_modified |
|
508 | 508 | '%s', |
509 | - '%d',//VNU_wp_user |
|
510 | - '%d',//parent |
|
511 | - '%d',//VNU_order |
|
512 | - '%s',//post_type |
|
509 | + '%d', //VNU_wp_user |
|
510 | + '%d', //parent |
|
511 | + '%d', //VNU_order |
|
512 | + '%s', //post_type |
|
513 | 513 | ); |
514 | 514 | $success = $wpdb->insert($wpdb->posts, |
515 | 515 | $insertion_array, |
516 | 516 | $datatypes_array); |
517 | - if( ! $success ){ |
|
517 | + if ( ! $success) { |
|
518 | 518 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array)); |
519 | 519 | return 0; |
520 | 520 | } |
@@ -527,78 +527,78 @@ discard block |
||
527 | 527 | * @param type $old_event |
528 | 528 | * @return int |
529 | 529 | */ |
530 | - private function _insert_venue_into_meta_table($cpt_id,$old_event){ |
|
530 | + private function _insert_venue_into_meta_table($cpt_id, $old_event) { |
|
531 | 531 | global $wpdb; |
532 | 532 | |
533 | 533 | //assume the country is the same as the organization's old settings |
534 | 534 | $country_iso = $this->get_migration_script()->get_default_country_iso(); |
535 | 535 | //find the state from the venue, or the organization, or just guess california |
536 | - if( ! $old_event['state']){ |
|
536 | + if ( ! $old_event['state']) { |
|
537 | 537 | $old_org_options = get_option('events_organization_settings'); |
538 | 538 | $state_name = stripslashes($old_org_options['organization_state']); |
539 | - }else{ |
|
539 | + } else { |
|
540 | 540 | $state_name = $old_event['state']; |
541 | 541 | } |
542 | - if ( ! $state_name ){ |
|
542 | + if ( ! $state_name) { |
|
543 | 543 | $state_name = 'CA'; |
544 | 544 | } |
545 | 545 | //get a state ID with the same name, if possible |
546 | - try{ |
|
547 | - $state = $this->get_migration_script()->get_or_create_state($state_name,$country_iso); |
|
546 | + try { |
|
547 | + $state = $this->get_migration_script()->get_or_create_state($state_name, $country_iso); |
|
548 | 548 | $state_id = $state['STA_ID']; |
549 | - }catch(EE_Error $e){ |
|
549 | + } catch (EE_Error $e) { |
|
550 | 550 | $this->add_error($e->getMessage()); |
551 | 551 | $state_id = 0; |
552 | 552 | } |
553 | 553 | //now insert into meta table |
554 | 554 | $insertion_array = array( |
555 | - 'VNU_ID'=>$cpt_id,//VNU_ID_fk |
|
556 | - 'VNU_address'=>stripslashes($old_event['address']),//VNU_address |
|
557 | - 'VNU_address2'=>stripslashes($old_event['address2']),//VNU_address2 |
|
558 | - 'VNU_city'=>stripslashes($old_event['city']),//VNU_city |
|
559 | - 'STA_ID'=>$state_id,//STA_ID |
|
560 | - 'CNT_ISO'=>$country_iso,//CNT_ISO |
|
561 | - 'VNU_zip'=>$old_event['zip'],//VNU_zip |
|
562 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
563 | - 'VNU_capacity'=>-1,//VNU_capacity |
|
564 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
565 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
566 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
567 | - 'VNU_google_map_link'=>'',//VNU_google_map_link |
|
555 | + 'VNU_ID'=>$cpt_id, //VNU_ID_fk |
|
556 | + 'VNU_address'=>stripslashes($old_event['address']), //VNU_address |
|
557 | + 'VNU_address2'=>stripslashes($old_event['address2']), //VNU_address2 |
|
558 | + 'VNU_city'=>stripslashes($old_event['city']), //VNU_city |
|
559 | + 'STA_ID'=>$state_id, //STA_ID |
|
560 | + 'CNT_ISO'=>$country_iso, //CNT_ISO |
|
561 | + 'VNU_zip'=>$old_event['zip'], //VNU_zip |
|
562 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
563 | + 'VNU_capacity'=>-1, //VNU_capacity |
|
564 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
565 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
566 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
567 | + 'VNU_google_map_link'=>'', //VNU_google_map_link |
|
568 | 568 | 'VNU_enable_for_gmap'=>true //VNU_enable_for_gmap |
569 | 569 | ); |
570 | 570 | $datatypes = array( |
571 | - '%d',//VNU_ID_fk |
|
572 | - '%s',//VNU_address |
|
573 | - '%s',//VNU_address2 |
|
574 | - '%s',//VNU_city |
|
575 | - '%d',//STA_ID |
|
576 | - '%s',//CNT_ISO |
|
577 | - '%s',//VNU_zip |
|
578 | - '%s',//VNU_phone |
|
579 | - '%d',//VNU_capacity |
|
580 | - '%s',//VNU_url |
|
581 | - '%s',//VNU_virtual_phone |
|
582 | - '%s',//VNU_virtual_url |
|
583 | - '%s',//VNU_google_map_link |
|
584 | - '%d',//VNU_enable_for_gmap |
|
571 | + '%d', //VNU_ID_fk |
|
572 | + '%s', //VNU_address |
|
573 | + '%s', //VNU_address2 |
|
574 | + '%s', //VNU_city |
|
575 | + '%d', //STA_ID |
|
576 | + '%s', //CNT_ISO |
|
577 | + '%s', //VNU_zip |
|
578 | + '%s', //VNU_phone |
|
579 | + '%d', //VNU_capacity |
|
580 | + '%s', //VNU_url |
|
581 | + '%s', //VNU_virtual_phone |
|
582 | + '%s', //VNU_virtual_url |
|
583 | + '%s', //VNU_google_map_link |
|
584 | + '%d', //VNU_enable_for_gmap |
|
585 | 585 | ); |
586 | - $success = $wpdb->insert($wpdb->prefix."esp_venue_meta",$insertion_array,$datatypes); |
|
587 | - if( ! $success ){ |
|
586 | + $success = $wpdb->insert($wpdb->prefix."esp_venue_meta", $insertion_array, $datatypes); |
|
587 | + if ( ! $success) { |
|
588 | 588 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $insertion_array, $datatypes)); |
589 | 589 | return 0; |
590 | 590 | } |
591 | 591 | return $wpdb->insert_id; |
592 | 592 | } |
593 | 593 | |
594 | - private function _insert_new_venue_to_event($new_event_id,$new_venue_id){ |
|
594 | + private function _insert_new_venue_to_event($new_event_id, $new_venue_id) { |
|
595 | 595 | global $wpdb; |
596 | - if( ! $new_event_id){ |
|
597 | - $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"),$new_event_id)); |
|
596 | + if ( ! $new_event_id) { |
|
597 | + $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $new_event_id)); |
|
598 | 598 | return 0; |
599 | 599 | } |
600 | - if( ! $new_venue_id){ |
|
601 | - $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"),$new_venue_id)); |
|
600 | + if ( ! $new_venue_id) { |
|
601 | + $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $new_venue_id)); |
|
602 | 602 | return 0; |
603 | 603 | } |
604 | 604 | $cols_n_values = array( |
@@ -607,12 +607,12 @@ discard block |
||
607 | 607 | 'EVV_primary'=>true |
608 | 608 | ); |
609 | 609 | $datatypes = array( |
610 | - '%d',//EVT_ID |
|
611 | - '%d',//VNU_ID |
|
612 | - '%d',//EVT_primary |
|
610 | + '%d', //EVT_ID |
|
611 | + '%d', //VNU_ID |
|
612 | + '%d', //EVT_primary |
|
613 | 613 | ); |
614 | - $success = $wpdb->insert($wpdb->prefix."esp_event_venue",$cols_n_values,$datatypes); |
|
615 | - if ( ! $success){ |
|
614 | + $success = $wpdb->insert($wpdb->prefix."esp_event_venue", $cols_n_values, $datatypes); |
|
615 | + if ( ! $success) { |
|
616 | 616 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_venue_rel, $this->_new_table, $cols_n_values, $datatypes)); |
617 | 617 | return 0; |
618 | 618 | } |
@@ -626,11 +626,11 @@ discard block |
||
626 | 626 | * @param int $new_cpt_id new post ID |
627 | 627 | * @return void (if there are errors though, adds them to the stage's error list |
628 | 628 | */ |
629 | - private function _convert_start_end_times($old_event,$new_cpt_id){ |
|
629 | + private function _convert_start_end_times($old_event, $new_cpt_id) { |
|
630 | 630 | $start_end_times = $this->_get_old_start_end_times($old_event['id']); |
631 | - foreach($start_end_times as $start_end_time){ |
|
632 | - $datetime_id = $this->_insert_new_datetime($start_end_time,$old_event,$new_cpt_id); |
|
633 | - if($datetime_id){ |
|
631 | + foreach ($start_end_times as $start_end_time) { |
|
632 | + $datetime_id = $this->_insert_new_datetime($start_end_time, $old_event, $new_cpt_id); |
|
633 | + if ($datetime_id) { |
|
634 | 634 | $this->get_migration_script()->set_mapping($this->_old_start_end_table, $start_end_time['id'], $this->_new_datetime_table, $datetime_id); |
635 | 635 | } |
636 | 636 | } |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | * @param type $old_event_id |
642 | 642 | * @return type |
643 | 643 | */ |
644 | - private function _get_old_start_end_times($old_event_id){ |
|
644 | + private function _get_old_start_end_times($old_event_id) { |
|
645 | 645 | global $wpdb; |
646 | - return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d",$old_event_id),ARRAY_A); |
|
646 | + return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d", $old_event_id), ARRAY_A); |
|
647 | 647 | } |
648 | 648 | /** |
649 | 649 | * Inserts a 4.1 datetime given the 3.1 start_end db row and event_details row |
@@ -652,40 +652,40 @@ discard block |
||
652 | 652 | * @param type $new_cpt_id |
653 | 653 | * @return int ID of new datetime |
654 | 654 | */ |
655 | - private function _insert_new_datetime($start_end_time_row,$old_event_row,$new_cpt_id){ |
|
655 | + private function _insert_new_datetime($start_end_time_row, $old_event_row, $new_cpt_id) { |
|
656 | 656 | global $wpdb; |
657 | 657 | $start_date = $old_event_row['start_date']; |
658 | 658 | $start_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['start_time']); |
659 | 659 | $end_date = $old_event_row['end_date']; |
660 | 660 | $end_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['end_time']); |
661 | 661 | $existing_datetimes = $this->_count_other_datetimes_exist_for_new_event($new_cpt_id); |
662 | - $start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$start_date $start_time:00",$old_event_row['timezone_string']); |
|
663 | - $end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$end_date $end_time:00",$old_event_row['timezone_string']); |
|
662 | + $start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$start_date $start_time:00", $old_event_row['timezone_string']); |
|
663 | + $end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$end_date $end_time:00", $old_event_row['timezone_string']); |
|
664 | 664 | $cols_n_values = array( |
665 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID |
|
666 | - 'DTT_EVT_start'=>$start_datetime_utc,//DTT_EVT_start |
|
667 | - 'DTT_EVT_end'=> $end_datetime_utc,//DTT_EVT_end |
|
668 | - 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'],//DTT_reg_limit |
|
669 | - 'DTT_sold'=>0,//note: we will increment this as registrations are added during the migration |
|
665 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID |
|
666 | + 'DTT_EVT_start'=>$start_datetime_utc, //DTT_EVT_start |
|
667 | + 'DTT_EVT_end'=> $end_datetime_utc, //DTT_EVT_end |
|
668 | + 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'], //DTT_reg_limit |
|
669 | + 'DTT_sold'=>0, //note: we will increment this as registrations are added during the migration |
|
670 | 670 | // 'DTT_is_primary'=> 0 == $existing_datetimes ,//DTT_is_primary... if count==0, then we'll call it the 'primary' |
671 | - 'DTT_order'=> $existing_datetimes,//DTT_order, just give it the same order as the count of how many datetimes already exist |
|
671 | + 'DTT_order'=> $existing_datetimes, //DTT_order, just give it the same order as the count of how many datetimes already exist |
|
672 | 672 | 'DTT_parent'=>0, |
673 | 673 | 'DTT_deleted'=>false |
674 | 674 | ); |
675 | 675 | $datatypes = array( |
676 | - '%d',//EVT_Id |
|
677 | - '%s',//DTT_EVT_start |
|
678 | - '%s',//DTT_EVT_end |
|
679 | - '%d',//DTT_reg_limit |
|
680 | - '%d',//DTT_sold |
|
676 | + '%d', //EVT_Id |
|
677 | + '%s', //DTT_EVT_start |
|
678 | + '%s', //DTT_EVT_end |
|
679 | + '%d', //DTT_reg_limit |
|
680 | + '%d', //DTT_sold |
|
681 | 681 | // '%d',//DTT_is_primary |
682 | - '%d',//DTT_order |
|
683 | - '%d',//DTT_parent |
|
684 | - '%d',//DTT_deleted |
|
682 | + '%d', //DTT_order |
|
683 | + '%d', //DTT_parent |
|
684 | + '%d', //DTT_deleted |
|
685 | 685 | ); |
686 | - $success = $wpdb->insert($this->_new_datetime_table,$cols_n_values,$datatypes); |
|
687 | - if ( ! $success){ |
|
688 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row,$start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes)); |
|
686 | + $success = $wpdb->insert($this->_new_datetime_table, $cols_n_values, $datatypes); |
|
687 | + if ( ! $success) { |
|
688 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row, $start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes)); |
|
689 | 689 | return 0; |
690 | 690 | } |
691 | 691 | return $wpdb->insert_id; |
@@ -698,9 +698,9 @@ discard block |
||
698 | 698 | * @param type $cpt_event_id |
699 | 699 | * @return int |
700 | 700 | */ |
701 | - private function _count_other_datetimes_exist_for_new_event($cpt_event_id){ |
|
701 | + private function _count_other_datetimes_exist_for_new_event($cpt_event_id) { |
|
702 | 702 | global $wpdb; |
703 | - $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d",$cpt_event_id)); |
|
703 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d", $cpt_event_id)); |
|
704 | 704 | return intval($count); |
705 | 705 | } |
706 | 706 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,32 +25,32 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEM_Currency extends EEM_Base{ |
|
28 | +class EEM_Currency extends EEM_Base { |
|
29 | 29 | // private instance of the Attendee object |
30 | 30 | protected static $_instance = NULL; |
31 | 31 | |
32 | - protected function __construct( $timezone = NULL ) { |
|
33 | - $this->singular_item = __('Currency','event_espresso'); |
|
34 | - $this->plural_item = __('Currencies','event_espresso'); |
|
32 | + protected function __construct($timezone = NULL) { |
|
33 | + $this->singular_item = __('Currency', 'event_espresso'); |
|
34 | + $this->plural_item = __('Currencies', 'event_espresso'); |
|
35 | 35 | $this->_tables = array( |
36 | 36 | 'Currency'=> new EE_Primary_Table('esp_currency', 'CUR_code') |
37 | 37 | ); |
38 | 38 | $this->_fields = array( |
39 | 39 | 'Currency'=>array( |
40 | - 'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code','event_espresso')), |
|
41 | - 'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular','event_espresso'), false), |
|
42 | - 'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural','event_espresso'), false), |
|
43 | - 'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign','event_espresso'), false), |
|
44 | - 'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places','event_espresso'), false, 2), |
|
45 | - 'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false,true), |
|
40 | + 'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')), |
|
41 | + 'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false), |
|
42 | + 'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false), |
|
43 | + 'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false), |
|
44 | + 'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2), |
|
45 | + 'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true), |
|
46 | 46 | )); |
47 | 47 | $this->_model_relations = array( |
48 | 48 | 'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'), |
49 | 49 | ); |
50 | 50 | //this model is generally available for reading |
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
51 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
52 | 52 | |
53 | - parent::__construct( $timezone ); |
|
53 | + parent::__construct($timezone); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * @param array $query_params see EEM_Base::get_all |
60 | 60 | * @return EE_Currency[] |
61 | 61 | */ |
62 | - public function get_all_active($query_params = array()){ |
|
62 | + public function get_all_active($query_params = array()) { |
|
63 | 63 | $query_params[0]['CUR_active'] = true; |
64 | - if( ! isset($query_params['order_by'])){ |
|
65 | - $query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC'); |
|
64 | + if ( ! isset($query_params['order_by'])) { |
|
65 | + $query_params['order_by'] = array('CUR_code'=>'ASC', 'CUR_single'=>'ASC'); |
|
66 | 66 | } |
67 | 67 | return $this->get_all($query_params); |
68 | 68 | } |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | * @param EE_PMT_Base $payment_method_type |
72 | 72 | * @return EE_Currency[] |
73 | 73 | */ |
74 | - public function get_all_currencies_usable_by($payment_method_type){ |
|
75 | - if($payment_method_type instanceof EE_PMT_Base && |
|
76 | - $payment_method_type->get_gateway()){ |
|
74 | + public function get_all_currencies_usable_by($payment_method_type) { |
|
75 | + if ($payment_method_type instanceof EE_PMT_Base && |
|
76 | + $payment_method_type->get_gateway()) { |
|
77 | 77 | $currencies_supported = $payment_method_type->get_gateway()->currencies_supported(); |
78 | - }else{ |
|
78 | + } else { |
|
79 | 79 | $currencies_supported = EE_Gateway::all_currencies_supported; |
80 | 80 | } |
81 | - if($currencies_supported == EE_Gateway::all_currencies_supported || empty( $currencies_supported ) ) { |
|
81 | + if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) { |
|
82 | 82 | $currencies = $this->get_all_active(); |
83 | - }else{ |
|
84 | - $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported)))); |
|
83 | + } else { |
|
84 | + $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN', $currencies_supported)))); |
|
85 | 85 | } |
86 | 86 | return $currencies; |
87 | 87 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | -if ( ! function_exists( 'espresso_get_template_part' )) { |
|
18 | +if ( ! function_exists('espresso_get_template_part')) { |
|
19 | 19 | /** |
20 | 20 | * espresso_get_template_part |
21 | 21 | * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @param string $name The name of the specialised template. |
26 | 26 | * @return string the html output for the formatted money value |
27 | 27 | */ |
28 | - function espresso_get_template_part( $slug = NULL, $name = NULL ) { |
|
29 | - EEH_Template::get_template_part( $slug, $name ); |
|
28 | + function espresso_get_template_part($slug = NULL, $name = NULL) { |
|
29 | + EEH_Template::get_template_part($slug, $name); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | -if ( ! function_exists( 'espresso_get_object_css_class' )) { |
|
35 | +if ( ! function_exists('espresso_get_object_css_class')) { |
|
36 | 36 | /** |
37 | 37 | * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
38 | 38 | * |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @param string $suffix added to the end of the generated class |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
46 | - return EEH_Template::get_object_css_class( $object, $prefix, $suffix ); |
|
45 | + function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return boolean |
71 | 71 | */ |
72 | 72 | public static function is_espresso_theme() { |
73 | - return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE; |
|
73 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public static function load_espresso_theme_functions() { |
82 | - if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) { |
|
83 | - if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) { |
|
84 | - require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' ); |
|
82 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
83 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
84 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @return array |
94 | 94 | */ |
95 | 95 | public static function get_espresso_themes() { |
96 | - if ( empty( EEH_Template::$_espresso_themes )) { |
|
97 | - $espresso_themes = glob( EE_PUBLIC . '*', GLOB_ONLYDIR ); |
|
98 | - if ( empty( $espresso_themes ) ) { |
|
96 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
97 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
98 | + if (empty($espresso_themes)) { |
|
99 | 99 | return array(); |
100 | 100 | } |
101 | - if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) { |
|
102 | - unset( $espresso_themes[ $key ] ); |
|
101 | + if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) { |
|
102 | + unset($espresso_themes[$key]); |
|
103 | 103 | } |
104 | 104 | EEH_Template::$_espresso_themes = array(); |
105 | - foreach ( $espresso_themes as $espresso_theme ) { |
|
106 | - EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme; |
|
105 | + foreach ($espresso_themes as $espresso_theme) { |
|
106 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | return EEH_Template::$_espresso_themes; |
@@ -122,16 +122,16 @@ discard block |
||
122 | 122 | * @param bool $return_string |
123 | 123 | * @return string the html output for the formatted money value |
124 | 124 | */ |
125 | - public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE ) { |
|
126 | - do_action( "get_template_part_{$slug}-{$name}", $slug, $name ); |
|
125 | + public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) { |
|
126 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
127 | 127 | $templates = array(); |
128 | 128 | $name = (string) $name; |
129 | - if ( $name != '' ) { |
|
129 | + if ($name != '') { |
|
130 | 130 | $templates[] = "{$slug}-{$name}.php"; |
131 | 131 | } |
132 | 132 | // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
133 | - if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) { |
|
134 | - EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string ); |
|
133 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) { |
|
134 | + EEH_Template::locate_template($templates, $template_args, TRUE, $return_string); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
@@ -182,26 +182,26 @@ discard block |
||
182 | 182 | * Used in places where you don't actually load the template, you just want to know if there's a custom version of it. |
183 | 183 | * @return mixed |
184 | 184 | */ |
185 | - public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) { |
|
185 | + public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) { |
|
186 | 186 | // first use WP locate_template to check for template in the current theme folder |
187 | - $template_path = locate_template( $templates ); |
|
187 | + $template_path = locate_template($templates); |
|
188 | 188 | |
189 | - if ( $check_if_custom && !empty( $template_path ) ) |
|
189 | + if ($check_if_custom && ! empty($template_path)) |
|
190 | 190 | return TRUE; |
191 | 191 | |
192 | 192 | // not in the theme |
193 | - if ( empty( $template_path )) { |
|
193 | + if (empty($template_path)) { |
|
194 | 194 | // not even a template to look for ? |
195 | - if ( empty( $templates )) { |
|
195 | + if (empty($templates)) { |
|
196 | 196 | // get post_type |
197 | - $post_type = EE_Registry::instance()->REQ->get( 'post_type' ); |
|
197 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
198 | 198 | // get array of EE Custom Post Types |
199 | 199 | $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
200 | 200 | // build template name based on request |
201 | - if ( isset( $EE_CPTs[ $post_type ] )) { |
|
202 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
203 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
204 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
201 | + if (isset($EE_CPTs[$post_type])) { |
|
202 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
203 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
204 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | // currently active EE template theme |
@@ -210,81 +210,81 @@ discard block |
||
210 | 210 | // array of paths to folders that may contain templates |
211 | 211 | $template_folder_paths = array( |
212 | 212 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
213 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
213 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
214 | 214 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
215 | 215 | EVENT_ESPRESSO_TEMPLATE_DIR |
216 | 216 | ); |
217 | 217 | |
218 | 218 | //add core plugin folders for checking only if we're not $check_if_custom |
219 | - if ( ! $check_if_custom ) { |
|
219 | + if ( ! $check_if_custom) { |
|
220 | 220 | $core_paths = array( |
221 | 221 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
222 | - EE_PUBLIC . $current_theme, |
|
222 | + EE_PUBLIC.$current_theme, |
|
223 | 223 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
224 | - EE_TEMPLATES . $current_theme, |
|
224 | + EE_TEMPLATES.$current_theme, |
|
225 | 225 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
226 | 226 | EE_PLUGIN_DIR_PATH |
227 | 227 | ); |
228 | - $template_folder_paths = array_merge( $template_folder_paths, $core_paths ); |
|
228 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | // now filter that array |
232 | - $template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths ); |
|
233 | - $templates = is_array( $templates ) ? $templates : array( $templates ); |
|
234 | - $template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths ); |
|
232 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths); |
|
233 | + $templates = is_array($templates) ? $templates : array($templates); |
|
234 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
235 | 235 | // array to hold all possible template paths |
236 | 236 | $full_template_paths = array(); |
237 | 237 | |
238 | 238 | // loop through $templates |
239 | - foreach ( $templates as $template ) { |
|
239 | + foreach ($templates as $template) { |
|
240 | 240 | // normalize directory separators |
241 | - $template = EEH_File::standardise_directory_separators( $template ); |
|
242 | - $file_name = basename( $template ); |
|
243 | - $template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) ); |
|
241 | + $template = EEH_File::standardise_directory_separators($template); |
|
242 | + $file_name = basename($template); |
|
243 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
244 | 244 | // while looping through all template folder paths |
245 | - foreach ( $template_folder_paths as $template_folder_path ) { |
|
245 | + foreach ($template_folder_paths as $template_folder_path) { |
|
246 | 246 | // normalize directory separators |
247 | - $template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path ); |
|
247 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
248 | 248 | // determine if any common base path exists between the two paths |
249 | 249 | $common_base_path = EEH_Template::_find_common_base_path( |
250 | - array( $template_folder_path, $template_path_minus_file_name ) |
|
250 | + array($template_folder_path, $template_path_minus_file_name) |
|
251 | 251 | ); |
252 | - if ( $common_base_path !== '' ) { |
|
252 | + if ($common_base_path !== '') { |
|
253 | 253 | // both paths have a common base, so just tack the filename onto our search path |
254 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name; |
|
254 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
255 | 255 | } else { |
256 | 256 | // no common base path, so let's just concatenate |
257 | - $resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template; |
|
257 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
258 | 258 | } |
259 | 259 | // build up our template locations array by adding our resolved paths |
260 | 260 | $full_template_paths[] = $resolved_path; |
261 | 261 | } |
262 | 262 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
263 | - array_unshift( $full_template_paths, $template ); |
|
263 | + array_unshift($full_template_paths, $template); |
|
264 | 264 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
265 | - array_unshift( $full_template_paths, get_stylesheet_directory() . DS . $file_name ); |
|
265 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
266 | 266 | } |
267 | 267 | // filter final array of full template paths |
268 | - $full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name ); |
|
268 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths, $file_name); |
|
269 | 269 | // now loop through our final array of template location paths and check each location |
270 | - foreach ( (array)$full_template_paths as $full_template_path ) { |
|
271 | - if ( is_readable( $full_template_path )) { |
|
272 | - $template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path ); |
|
270 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
271 | + if (is_readable($full_template_path)) { |
|
272 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
273 | 273 | // hook that can be used to display the full template path that will be used |
274 | - do_action( 'AHEE__EEH_Template__locate_template__full_template_path', $template_path ); |
|
274 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
275 | 275 | break; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | } |
279 | 279 | // if we got it and you want to see it... |
280 | - if ( $template_path && $load && ! $check_if_custom ) { |
|
281 | - if ( $return_string ) { |
|
282 | - return EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
280 | + if ($template_path && $load && ! $check_if_custom) { |
|
281 | + if ($return_string) { |
|
282 | + return EEH_Template::display_template($template_path, $template_args, TRUE); |
|
283 | 283 | } else { |
284 | - EEH_Template::display_template( $template_path, $template_args, FALSE ); |
|
284 | + EEH_Template::display_template($template_path, $template_args, FALSE); |
|
285 | 285 | } |
286 | 286 | } |
287 | - return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path; |
|
287 | + return $check_if_custom && ! empty($template_path) ? TRUE : $template_path; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -297,21 +297,21 @@ discard block |
||
297 | 297 | * @param array $paths |
298 | 298 | * @return string |
299 | 299 | */ |
300 | - protected static function _find_common_base_path( $paths ) { |
|
300 | + protected static function _find_common_base_path($paths) { |
|
301 | 301 | $last_offset = 0; |
302 | 302 | $common_base_path = ''; |
303 | - while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) { |
|
303 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
304 | 304 | $dir_length = $index - $last_offset + 1; |
305 | - $directory = substr( $paths[ 0 ], $last_offset, $dir_length ); |
|
306 | - foreach ( $paths as $path ) { |
|
307 | - if ( substr( $path, $last_offset, $dir_length ) != $directory ) { |
|
305 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
306 | + foreach ($paths as $path) { |
|
307 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
308 | 308 | return $common_base_path; |
309 | 309 | } |
310 | 310 | } |
311 | 311 | $common_base_path .= $directory; |
312 | 312 | $last_offset = $index + 1; |
313 | 313 | } |
314 | - return substr( $common_base_path, 0, -1 ); |
|
314 | + return substr($common_base_path, 0, -1); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
324 | 324 | * @return mixed string |
325 | 325 | */ |
326 | - public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) { |
|
326 | + public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) { |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * These two filters are intended for last minute changes to templates being loaded and/or template arg |
@@ -334,26 +334,26 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @since 4.6.0 |
336 | 336 | */ |
337 | - $template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path ); |
|
338 | - $template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args ); |
|
337 | + $template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
338 | + $template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
339 | 339 | |
340 | 340 | // you gimme nuttin - YOU GET NUTTIN !! |
341 | - if ( ! $template_path || ! is_readable( $template_path )) { |
|
341 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
342 | 342 | return ''; |
343 | 343 | } |
344 | 344 | // if $template_args are not in an array, then make it so |
345 | - if ( ! is_array( $template_args ) && ! is_object( $template_args )) { |
|
346 | - $template_args = array( $template_args ); |
|
345 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
346 | + $template_args = array($template_args); |
|
347 | 347 | } |
348 | - extract( (array) $template_args); |
|
348 | + extract((array) $template_args); |
|
349 | 349 | |
350 | - if ( $return_string ) { |
|
350 | + if ($return_string) { |
|
351 | 351 | // because we want to return a string, we are going to capture the output |
352 | 352 | ob_start(); |
353 | - include( $template_path ); |
|
353 | + include($template_path); |
|
354 | 354 | return ob_get_clean(); |
355 | 355 | } else { |
356 | - include( $template_path ); |
|
356 | + include($template_path); |
|
357 | 357 | } |
358 | 358 | return ''; |
359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
371 | 371 | * @param string $suffix added to the end of the generated class |
372 | 372 | * @return string |
373 | 373 | */ |
374 | - public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) { |
|
374 | + public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') { |
|
375 | 375 | // in the beginning... |
376 | - $prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : ''; |
|
376 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
377 | 377 | // da muddle |
378 | 378 | $class = ''; |
379 | 379 | // the end |
380 | - $suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : ''; |
|
380 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
381 | 381 | // is the passed object an EE object ? |
382 | - if ( $object instanceof EE_Base_Class ) { |
|
382 | + if ($object instanceof EE_Base_Class) { |
|
383 | 383 | // grab the exact type of object |
384 | - $obj_class = get_class( $object ); |
|
384 | + $obj_class = get_class($object); |
|
385 | 385 | // depending on the type of object... |
386 | - switch ( $obj_class ) { |
|
386 | + switch ($obj_class) { |
|
387 | 387 | // no specifics just yet... |
388 | 388 | default : |
389 | - $class = strtolower( str_replace( '_', '-', $obj_class )); |
|
390 | - $class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : ''; |
|
389 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
390 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | } |
394 | - return $prefix . $class . $suffix; |
|
394 | + return $prefix.$class.$suffix; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -407,54 +407,54 @@ discard block |
||
407 | 407 | * @param string $cur_code_span_class |
408 | 408 | * @return string the html output for the formatted money value |
409 | 409 | */ |
410 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) { |
|
410 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') { |
|
411 | 411 | // ensure amount was received |
412 | - if ( is_null( $amount ) ) { |
|
413 | - $msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' ); |
|
414 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
412 | + if (is_null($amount)) { |
|
413 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
414 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
415 | 415 | return ''; |
416 | 416 | } |
417 | 417 | //ensure amount is float |
418 | - $amount = apply_filters( 'FHEE__EEH_Template__format_currency__raw_amount', (float) $amount ); |
|
419 | - $CNT_ISO = apply_filters( 'FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount ); |
|
418 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
419 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
420 | 420 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
421 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw ); |
|
421 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
422 | 422 | // still a number or was amount converted to a string like "free" ? |
423 | - if ( is_float( $amount_formatted )) { |
|
423 | + if (is_float($amount_formatted)) { |
|
424 | 424 | // was a country ISO code passed ? if so generate currency config object for that country |
425 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL; |
|
425 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL; |
|
426 | 426 | // verify results |
427 | - if ( ! $mny instanceof EE_Currency_Config ) { |
|
427 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
428 | 428 | // set default config country currency settings |
429 | 429 | $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config(); |
430 | 430 | } |
431 | 431 | // format float |
432 | - $amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds ); |
|
432 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
433 | 433 | // add formatting ? |
434 | - if ( ! $return_raw ) { |
|
434 | + if ( ! $return_raw) { |
|
435 | 435 | // add currency sign |
436 | - if( $mny->sign_b4 ){ |
|
437 | - if( $amount >= 0 ){ |
|
438 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
439 | - }else{ |
|
440 | - $amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted ); |
|
436 | + if ($mny->sign_b4) { |
|
437 | + if ($amount >= 0) { |
|
438 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
439 | + } else { |
|
440 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
441 | 441 | } |
442 | 442 | |
443 | - }else{ |
|
444 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
443 | + } else { |
|
444 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // filter to allow global setting of display_code |
448 | - $display_code = apply_filters( 'FHEE__EEH_Template__format_currency__display_code', $display_code ); |
|
448 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
449 | 449 | |
450 | 450 | // add currency code ? |
451 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
451 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
452 | 452 | } |
453 | 453 | // filter results |
454 | - $amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw ); |
|
454 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw); |
|
455 | 455 | } |
456 | 456 | // clean up vars |
457 | - unset( $mny ); |
|
457 | + unset($mny); |
|
458 | 458 | // return formatted currency amount |
459 | 459 | return $amount_formatted; |
460 | 460 | } |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | * @param string $schema 'UPPER', 'lower', or 'Sentence' |
470 | 470 | * @return string The localized label for the status id. |
471 | 471 | */ |
472 | - public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) { |
|
472 | + public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') { |
|
473 | 473 | /** @type EEM_Status $EEM_Status */ |
474 | - $EEM_Status = EE_Registry::instance()->load_model( 'Status' ); |
|
475 | - $status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema ); |
|
476 | - return $status[ $status_id ]; |
|
474 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
475 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema); |
|
476 | + return $status[$status_id]; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -486,9 +486,9 @@ discard block |
||
486 | 486 | * @param string $icon |
487 | 487 | * @return string the html output for the button |
488 | 488 | */ |
489 | - public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) { |
|
490 | - $label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label; |
|
491 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>'; |
|
489 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') { |
|
490 | + $label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label; |
|
491 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>'; |
|
492 | 492 | return $button; |
493 | 493 | } |
494 | 494 | |
@@ -505,21 +505,21 @@ discard block |
||
505 | 505 | * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
506 | 506 | * @return string generated link |
507 | 507 | */ |
508 | - public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) { |
|
508 | + public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) { |
|
509 | 509 | |
510 | - if ( ! $page ) |
|
511 | - $page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page; |
|
510 | + if ( ! $page) |
|
511 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
512 | 512 | |
513 | - if ( ! $action ) |
|
514 | - $action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action; |
|
513 | + if ( ! $action) |
|
514 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
515 | 515 | |
516 | 516 | $action = empty($action) ? 'default' : $action; |
517 | 517 | |
518 | 518 | |
519 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
520 | - $icon = !$icon_style ? ' dashicons-editor-help' : $icon_style; |
|
521 | - $help_text = !$help_text ? '' : $help_text; |
|
522 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
519 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
520 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
521 | + $help_text = ! $help_text ? '' : $help_text; |
|
522 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>'; |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | |
@@ -531,31 +531,31 @@ discard block |
||
531 | 531 | * @param EE_Help_Tour |
532 | 532 | * @return string html |
533 | 533 | */ |
534 | - public static function help_tour_stops_generator( EE_Help_Tour $tour ) { |
|
534 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) { |
|
535 | 535 | $id = $tour->get_slug(); |
536 | 536 | $stops = $tour->get_stops(); |
537 | 537 | |
538 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
538 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
539 | 539 | |
540 | - foreach ( $stops as $stop ) { |
|
541 | - $data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
542 | - $data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
540 | + foreach ($stops as $stop) { |
|
541 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
542 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
543 | 543 | |
544 | 544 | //if container is set to modal then let's make sure we set the options accordingly |
545 | - if ( empty( $data_id ) && empty( $data_class ) ) { |
|
545 | + if (empty($data_id) && empty($data_class)) { |
|
546 | 546 | $stop['options']['modal'] = true; |
547 | 547 | $stop['options']['expose'] = true; |
548 | 548 | } |
549 | 549 | |
550 | - $custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
551 | - $button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
550 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
551 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
552 | 552 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
553 | 553 | |
554 | 554 | //options |
555 | - if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) { |
|
555 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
556 | 556 | $options = ' data-options="'; |
557 | - foreach ( $stop['options'] as $option => $value ) { |
|
558 | - $options .= $option . ':' . $value . ';'; |
|
557 | + foreach ($stop['options'] as $option => $value) { |
|
558 | + $options .= $option.':'.$value.';'; |
|
559 | 559 | } |
560 | 560 | $options .= '"'; |
561 | 561 | } else { |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | } |
564 | 564 | |
565 | 565 | //let's put all together |
566 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
566 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | $content .= '</ol>'; |
@@ -584,31 +584,31 @@ discard block |
||
584 | 584 | * @throws EE_Error |
585 | 585 | * @return string html structure for status. |
586 | 586 | */ |
587 | - public static function status_legend( $status_array, $active_status = '' ) { |
|
588 | - if ( !is_array( $status_array ) ) |
|
589 | - throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') ); |
|
587 | + public static function status_legend($status_array, $active_status = '') { |
|
588 | + if ( ! is_array($status_array)) |
|
589 | + throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso')); |
|
590 | 590 | |
591 | 591 | $setup_array = array(); |
592 | - foreach ( $status_array as $item => $status ) { |
|
592 | + foreach ($status_array as $item => $status) { |
|
593 | 593 | $setup_array[$item] = array( |
594 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
595 | - 'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ), |
|
594 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
595 | + 'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'), |
|
596 | 596 | 'status' => $status |
597 | 597 | ); |
598 | 598 | } |
599 | 599 | |
600 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
601 | - $content .= '<h3>' . __('Status Legend', 'event_espresso') . '</h3>' . "\n"; |
|
602 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
603 | - foreach ( $setup_array as $item => $details ) { |
|
600 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
601 | + $content .= '<h3>'.__('Status Legend', 'event_espresso').'</h3>'."\n"; |
|
602 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
603 | + foreach ($setup_array as $item => $details) { |
|
604 | 604 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
605 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
606 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
607 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
608 | - $content .= '</dt>' . "\n"; |
|
605 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
606 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
607 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
608 | + $content .= '</dt>'."\n"; |
|
609 | 609 | } |
610 | - $content .= '</dl>' . "\n"; |
|
611 | - $content .= '</div>' . "\n"; |
|
610 | + $content .= '</dl>'."\n"; |
|
611 | + $content .= '</div>'."\n"; |
|
612 | 612 | return $content; |
613 | 613 | } |
614 | 614 | |
@@ -621,8 +621,8 @@ discard block |
||
621 | 621 | * @return string |
622 | 622 | */ |
623 | 623 | public static function layout_array_as_table($data) { |
624 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) { |
|
625 | - $data = (array)$data; |
|
624 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
625 | + $data = (array) $data; |
|
626 | 626 | } |
627 | 627 | ob_start(); |
628 | 628 | if (is_array($data)) { |
@@ -635,10 +635,10 @@ discard block |
||
635 | 635 | ?> |
636 | 636 | <tr> |
637 | 637 | <td> |
638 | - <?php echo $data_key;?> |
|
638 | + <?php echo $data_key; ?> |
|
639 | 639 | </td> |
640 | 640 | <td> |
641 | - <?php echo self::layout_array_as_table($data_values);?> |
|
641 | + <?php echo self::layout_array_as_table($data_values); ?> |
|
642 | 642 | </td> |
643 | 643 | </tr> |
644 | 644 | <?php |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | <ul> |
653 | 653 | <?php |
654 | 654 | foreach ($data as $datum) { |
655 | - echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>"; |
|
655 | + echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>"; |
|
656 | 656 | }?> |
657 | 657 | </ul> |
658 | 658 | <?php |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | * |
683 | 683 | * @return string |
684 | 684 | */ |
685 | - public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
686 | - echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label ); |
|
685 | + public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
686 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | |
@@ -707,13 +707,13 @@ discard block |
||
707 | 707 | * ) |
708 | 708 | * @return string |
709 | 709 | */ |
710 | - public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) { |
|
710 | + public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) { |
|
711 | 711 | $page_links = array(); |
712 | 712 | $disable_first = $disable_last = ''; |
713 | 713 | $total_items = (int) $total_items; |
714 | 714 | $per_page = (int) $per_page; |
715 | 715 | $current = (int) $current; |
716 | - $paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name ); |
|
716 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
717 | 717 | |
718 | 718 | //filter items_label |
719 | 719 | $items_label = apply_filters( |
@@ -721,68 +721,68 @@ discard block |
||
721 | 721 | $items_label |
722 | 722 | ); |
723 | 723 | |
724 | - if ( empty( $items_label ) |
|
725 | - || ! is_array( $items_label ) |
|
726 | - || ! isset( $items_label['single'] ) |
|
727 | - || ! isset( $items_label['plural'] ) ) { |
|
724 | + if (empty($items_label) |
|
725 | + || ! is_array($items_label) |
|
726 | + || ! isset($items_label['single']) |
|
727 | + || ! isset($items_label['plural'])) { |
|
728 | 728 | $items_label = array( |
729 | - 'single' => __( '1 item', 'event_espresso' ), |
|
730 | - 'plural' => __( '%s items', 'event_espresso' ) |
|
729 | + 'single' => __('1 item', 'event_espresso'), |
|
730 | + 'plural' => __('%s items', 'event_espresso') |
|
731 | 731 | ); |
732 | 732 | } else { |
733 | 733 | $items_label = array( |
734 | - 'single' => '1 ' . esc_html( $items_label['single'] ), |
|
735 | - 'plural' => '%s ' . esc_html( $items_label['plural'] ) |
|
734 | + 'single' => '1 '.esc_html($items_label['single']), |
|
735 | + 'plural' => '%s '.esc_html($items_label['plural']) |
|
736 | 736 | ); |
737 | 737 | } |
738 | 738 | |
739 | - $total_pages = ceil( $total_items / $per_page ); |
|
739 | + $total_pages = ceil($total_items / $per_page); |
|
740 | 740 | |
741 | - if ( $total_pages <= 1 ) |
|
741 | + if ($total_pages <= 1) |
|
742 | 742 | return ''; |
743 | 743 | |
744 | - $item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single']; |
|
744 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
745 | 745 | |
746 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
746 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
747 | 747 | |
748 | - if ( $current === 1 ) { |
|
748 | + if ($current === 1) { |
|
749 | 749 | $disable_first = ' disabled'; |
750 | 750 | } |
751 | - if ( $current == $total_pages ) { |
|
751 | + if ($current == $total_pages) { |
|
752 | 752 | $disable_last = ' disabled'; |
753 | 753 | } |
754 | 754 | |
755 | - $page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>", |
|
756 | - 'first-page' . $disable_first, |
|
757 | - esc_attr__( 'Go to the first page' ), |
|
758 | - esc_url( remove_query_arg( $paged_arg_name, $url ) ), |
|
755 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
756 | + 'first-page'.$disable_first, |
|
757 | + esc_attr__('Go to the first page'), |
|
758 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
759 | 759 | '«' |
760 | 760 | ); |
761 | 761 | |
762 | 762 | $page_links[] = sprintf( |
763 | 763 | '<a class="%s" title="%s" href="%s">%s</a>', |
764 | - 'prev-page' . $disable_first, |
|
765 | - esc_attr__( 'Go to the previous page' ), |
|
766 | - esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ), |
|
764 | + 'prev-page'.$disable_first, |
|
765 | + esc_attr__('Go to the previous page'), |
|
766 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
767 | 767 | '‹' |
768 | 768 | ); |
769 | 769 | |
770 | - if ( ! $show_num_field ) { |
|
770 | + if ( ! $show_num_field) { |
|
771 | 771 | $html_current_page = $current; |
772 | 772 | } else { |
773 | - $html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
774 | - esc_attr__( 'Current page' ), |
|
773 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
774 | + esc_attr__('Current page'), |
|
775 | 775 | $current, |
776 | - strlen( $total_pages ) |
|
776 | + strlen($total_pages) |
|
777 | 777 | ); |
778 | 778 | } |
779 | 779 | |
780 | 780 | $html_total_pages = sprintf( |
781 | 781 | '<span class="total-pages">%s</span>', |
782 | - number_format_i18n( $total_pages ) |
|
782 | + number_format_i18n($total_pages) |
|
783 | 783 | ); |
784 | 784 | $page_links[] = sprintf( |
785 | - _x( '%3$s%1$s of %2$s%4$s', 'paging' ), |
|
785 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
786 | 786 | $html_current_page, |
787 | 787 | $html_total_pages, |
788 | 788 | '<span class="paging-input">', |
@@ -791,29 +791,29 @@ discard block |
||
791 | 791 | |
792 | 792 | $page_links[] = sprintf( |
793 | 793 | '<a class="%s" title="%s" href="%s">%s</a>', |
794 | - 'next-page' . $disable_last, |
|
795 | - esc_attr__( 'Go to the next page' ), |
|
796 | - esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ), |
|
794 | + 'next-page'.$disable_last, |
|
795 | + esc_attr__('Go to the next page'), |
|
796 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
797 | 797 | '›' |
798 | 798 | ); |
799 | 799 | |
800 | 800 | $page_links[] = sprintf( |
801 | 801 | '<a class="%s" title="%s" href="%s">%s</a>', |
802 | - 'last-page' . $disable_last, |
|
803 | - esc_attr__( 'Go to the last page' ), |
|
804 | - esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ), |
|
802 | + 'last-page'.$disable_last, |
|
803 | + esc_attr__('Go to the last page'), |
|
804 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
805 | 805 | '»' |
806 | 806 | ); |
807 | 807 | |
808 | - $output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>'; |
|
808 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
809 | 809 | // set page class |
810 | - if ( $total_pages ) { |
|
810 | + if ($total_pages) { |
|
811 | 811 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
812 | 812 | } else { |
813 | 813 | $page_class = ' no-pages'; |
814 | 814 | } |
815 | 815 | |
816 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
816 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | //add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 ); |
830 | 830 | |
831 | 831 | |
832 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
832 | +if ( ! function_exists('espresso_pagination')) { |
|
833 | 833 | /** |
834 | 834 | * espresso_pagination |
835 | 835 | * |
@@ -841,21 +841,21 @@ discard block |
||
841 | 841 | $big = 999999999; // need an unlikely integer |
842 | 842 | $pagination = paginate_links( |
843 | 843 | array( |
844 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
844 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
845 | 845 | 'format' => '?paged=%#%', |
846 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
846 | + 'current' => max(1, get_query_var('paged')), |
|
847 | 847 | 'total' => $wp_query->max_num_pages, |
848 | 848 | 'show_all' => true, |
849 | 849 | 'end_size' => 10, |
850 | 850 | 'mid_size' => 6, |
851 | 851 | 'prev_next' => true, |
852 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
853 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
852 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
853 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
854 | 854 | 'type' => 'plain', |
855 | 855 | 'add_args' => false, |
856 | 856 | 'add_fragment' => '' |
857 | 857 | ) |
858 | 858 | ); |
859 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
859 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | \ No newline at end of file |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | * @param array $ee_gmaps_opts array of attributes required for the map link generation |
22 | 22 | * @return string (link to map!) |
23 | 23 | */ |
24 | - public static function google_map( $ee_gmaps_opts ){ |
|
25 | - |
|
26 | - $ee_map_width = isset( $ee_gmaps_opts['ee_map_width'] ) && ! empty( $ee_gmaps_opts['ee_map_width'] ) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
27 | - $ee_map_height = isset( $ee_gmaps_opts['ee_map_height'] ) && ! empty( $ee_gmaps_opts['ee_map_height'] ) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
28 | - $ee_map_zoom = isset( $ee_gmaps_opts['ee_map_zoom'] ) && ! empty( $ee_gmaps_opts['ee_map_zoom'] ) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
29 | - $ee_map_nav_display = isset( $ee_gmaps_opts['ee_map_nav_display'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_display'] ) ? 'true' : 'false'; |
|
30 | - $ee_map_nav_size = isset( $ee_gmaps_opts['ee_map_nav_size'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_size'] )? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
31 | - $ee_map_type_control = isset( $ee_gmaps_opts['ee_map_type_control'] ) && ! empty( $ee_gmaps_opts['ee_map_type_control'] )? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
32 | - $static_url = isset( $ee_gmaps_opts['ee_static_url'] ) && ! empty( $ee_gmaps_opts['ee_static_url'] )? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
33 | - |
|
34 | - if( isset( $ee_gmaps_opts['ee_map_align'] ) && ! empty( $ee_gmaps_opts['ee_map_align'] )){ |
|
35 | - switch( $ee_gmaps_opts['ee_map_align'] ){ |
|
24 | + public static function google_map($ee_gmaps_opts) { |
|
25 | + |
|
26 | + $ee_map_width = isset($ee_gmaps_opts['ee_map_width']) && ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
27 | + $ee_map_height = isset($ee_gmaps_opts['ee_map_height']) && ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
28 | + $ee_map_zoom = isset($ee_gmaps_opts['ee_map_zoom']) && ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
29 | + $ee_map_nav_display = isset($ee_gmaps_opts['ee_map_nav_display']) && ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
30 | + $ee_map_nav_size = isset($ee_gmaps_opts['ee_map_nav_size']) && ! empty($ee_gmaps_opts['ee_map_nav_size']) ? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
31 | + $ee_map_type_control = isset($ee_gmaps_opts['ee_map_type_control']) && ! empty($ee_gmaps_opts['ee_map_type_control']) ? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
32 | + $static_url = isset($ee_gmaps_opts['ee_static_url']) && ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
33 | + |
|
34 | + if (isset($ee_gmaps_opts['ee_map_align']) && ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
35 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
36 | 36 | case "left": |
37 | 37 | $map_align = 'ee-gmap-align-left left'; |
38 | 38 | break; |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | |
54 | 54 | // Determine whether user has set a hardoded url to use and |
55 | 55 | // if so display a Google static iframe map else run V3 api |
56 | - if( $static_url ) { |
|
56 | + if ($static_url) { |
|
57 | 57 | |
58 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
59 | - $html .= '<iframe src="' . $static_url . '&output=embed" style="width: ' . $ee_map_width .'px; height: ' . $ee_map_height . 'px;" frameborder="0" scrolling="no">'; |
|
58 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
59 | + $html .= '<iframe src="'.$static_url.'&output=embed" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;" frameborder="0" scrolling="no">'; |
|
60 | 60 | $html .= '</iframe>'; |
61 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
61 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
62 | 62 | $html .= '</div>'; |
63 | 63 | return $html; |
64 | 64 | |
65 | 65 | } else { |
66 | 66 | |
67 | - EEH_Maps::$gmap_vars[ $ee_gmaps_opts['map_ID'] ] = array( |
|
67 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
68 | 68 | 'map_ID' => $ee_gmaps_opts['map_ID'], |
69 | 69 | 'ee_map_zoom' => $ee_map_zoom, |
70 | 70 | 'ee_map_nav_display' => $ee_map_nav_display, |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | ); |
75 | 75 | |
76 | 76 | $html = '<div class="ee-gmap-wrapper '.$map_align.';">'; |
77 | - $html .= '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] .'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
77 | + $html .= '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
78 | 78 | $html .= '</div>'; |
79 | 79 | |
80 | - wp_enqueue_script( 'gmap_api' ); |
|
81 | - wp_enqueue_script( 'ee_gmap' ); |
|
82 | - add_action( 'wp_footer', array( 'EEH_Maps', 'footer_enqueue_script' )); |
|
80 | + wp_enqueue_script('gmap_api'); |
|
81 | + wp_enqueue_script('ee_gmap'); |
|
82 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
83 | 83 | |
84 | 84 | return $html; |
85 | 85 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return void |
95 | 95 | */ |
96 | 96 | public static function footer_enqueue_script() { |
97 | - wp_localize_script( 'ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars ); |
|
97 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | public static function espresso_google_map_js() { |
106 | 106 | $api_url = sprintf( |
107 | 107 | "https://maps.googleapis.com/maps/api/js?key=%s", |
108 | - apply_filters( 'FHEE__EEH_Maps__espresso_google_maps_js__api_key', EE_Registry::instance()->CFG->map_settings->google_map_api_key ) |
|
108 | + apply_filters('FHEE__EEH_Maps__espresso_google_maps_js__api_key', EE_Registry::instance()->CFG->map_settings->google_map_api_key) |
|
109 | 109 | ); |
110 | - wp_register_script( 'gmap_api', $api_url, array('jquery'), NULL, TRUE ); |
|
111 | - wp_register_script( 'ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE ); |
|
110 | + wp_register_script('gmap_api', $api_url, array('jquery'), NULL, TRUE); |
|
111 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return string (link to map!) |
118 | 118 | */ |
119 | 119 | public static function google_map_link($atts) { |
120 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
120 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
121 | 121 | extract($atts); |
122 | 122 | /** @var string $address */ |
123 | 123 | /** @var string $city */ |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | $id = isset($id) ? $id : 'not_set'; |
137 | 137 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
138 | 138 | |
139 | - $address_string = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : ''); |
|
139 | + $address_string = ($address != '' ? $address : '').($city != '' ? ','.$city : '').($state != '' ? ','.$state : '').($zip != '' ? ','.$zip : '').($country != '' ? ','.$country : ''); |
|
140 | 140 | |
141 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode( $address_string )); |
|
141 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
142 | 142 | |
143 | 143 | switch ($type) { |
144 | 144 | case 'text': |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | case 'map': |
154 | 154 | $scheme = is_ssl() ? 'https://' : 'http://'; |
155 | 155 | |
156 | - $api_key = apply_filters( 'FHEE__EEH_Maps__espresso_google_maps_link__api_key', EE_Registry::instance()->CFG->map_settings->google_map_api_key ); |
|
156 | + $api_key = apply_filters('FHEE__EEH_Maps__espresso_google_maps_link__api_key', EE_Registry::instance()->CFG->map_settings->google_map_api_key); |
|
157 | 157 | |
158 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2( $scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode( $address_string ) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode( $address_string ) . '&sensor=false&key=' . $api_key ) . '" /></a>'; |
|
158 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false&key='.$api_key).'" /></a>'; |
|
159 | 159 | } |
160 | 160 | |
161 | - return '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
161 | + return '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 |
@@ -26,12 +26,12 @@ |
||
26 | 26 | <input type="text" id="ee-google-map-api-key" class="regular-text" name="google_map_api_key" value="<?php echo $map_settings->google_map_api_key; ?>" /> |
27 | 27 | <p class="description"> |
28 | 28 | <?php |
29 | - printf( |
|
30 | - __('An API key is now required to use the Google Maps API: %1$sclick here to get an API key%2$s', 'event_espresso'), |
|
31 | - '<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,static_maps_backend&keyType=CLIENT_SIDE&reusekey=true" target="_blank">', |
|
32 | - '</a>' |
|
33 | - ); |
|
34 | - ?> |
|
29 | + printf( |
|
30 | + __('An API key is now required to use the Google Maps API: %1$sclick here to get an API key%2$s', 'event_espresso'), |
|
31 | + '<a href="https://console.developers.google.com/flows/enableapi?apiid=maps_backend,geocoding_backend,directions_backend,distance_matrix_backend,elevation_backend,static_maps_backend&keyType=CLIENT_SIDE&reusekey=true" target="_blank">', |
|
32 | + '</a>' |
|
33 | + ); |
|
34 | + ?> |
|
35 | 35 | </p> |
36 | 36 | </td> |
37 | 37 | </tr> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | |
63 | 63 | |
64 | 64 | protected function _init_page_props() { |
65 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
65 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
66 | 66 | $this->page_slug = EE_VENUES_PG_SLUG; |
67 | 67 | $this->_admin_base_url = EE_VENUES_ADMIN_URL; |
68 | - $this->_admin_base_path = EE_ADMIN_PAGES . 'venues'; |
|
68 | + $this->_admin_base_path = EE_ADMIN_PAGES.'venues'; |
|
69 | 69 | $this->page_label = __('Event Venues', 'event_espresso'); |
70 | 70 | $this->_cpt_model_names = array( |
71 | 71 | 'create_new' => 'EEM_Venue', |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | 'edit' => __('Update Venue', 'event_espresso'), |
109 | 109 | 'add_category' => __('Save New Category', 'event_espresso'), |
110 | 110 | 'edit_category' => __('Update Category', 'event_espresso'), |
111 | - 'google_map_settings' => __( 'Update Settings', 'event_espresso' ) |
|
111 | + 'google_map_settings' => __('Update Settings', 'event_espresso') |
|
112 | 112 | ) |
113 | 113 | ); |
114 | 114 | } |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | //load field generator helper |
124 | 124 | |
125 | 125 | //is there a vnu_id in the request? |
126 | - $vnu_id = ! empty( $this->_req_data['VNU_ID'] ) && ! is_array( $this->_req_data['VNU_ID'] ) ? $this->_req_data['VNU_ID'] : 0; |
|
127 | - $vnu_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $vnu_id; |
|
126 | + $vnu_id = ! empty($this->_req_data['VNU_ID']) && ! is_array($this->_req_data['VNU_ID']) ? $this->_req_data['VNU_ID'] : 0; |
|
127 | + $vnu_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $vnu_id; |
|
128 | 128 | |
129 | 129 | $this->_page_routes = array( |
130 | 130 | 'default' => array( |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | ), |
143 | 143 | 'trash_venue' => array( |
144 | 144 | 'func' => '_trash_or_restore_venue', |
145 | - 'args' => array( 'venue_status' => 'trash' ), |
|
145 | + 'args' => array('venue_status' => 'trash'), |
|
146 | 146 | 'noheader' => TRUE, |
147 | 147 | 'capability' => 'ee_delete_venue', |
148 | 148 | 'obj_id' => $vnu_id |
149 | 149 | ), |
150 | 150 | 'trash_venues' => array( |
151 | 151 | 'func' => '_trash_or_restore_venues', |
152 | - 'args' => array( 'venue_status' => 'trash' ), |
|
152 | + 'args' => array('venue_status' => 'trash'), |
|
153 | 153 | 'noheader' => TRUE, |
154 | 154 | 'capability' => 'ee_delete_venues' |
155 | 155 | ), |
156 | 156 | 'restore_venue' => array( |
157 | 157 | 'func' => '_trash_or_restore_venue', |
158 | - 'args' => array( 'venue_status' => 'draft' ), |
|
158 | + 'args' => array('venue_status' => 'draft'), |
|
159 | 159 | 'noheader' => TRUE, |
160 | 160 | 'capability' => 'ee_delete_venue', |
161 | 161 | 'obj_id' => $vnu_id |
162 | 162 | ), |
163 | 163 | 'restore_venues' => array( |
164 | 164 | 'func' => '_trash_or_restore_venues', |
165 | - 'args' => array( 'venue_status' => 'draft' ), |
|
165 | + 'args' => array('venue_status' => 'draft'), |
|
166 | 166 | 'noheader' => TRUE, |
167 | 167 | 'capability' => 'ee_delete_venues' |
168 | 168 | ), |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | 'filename' => 'venues_overview_views_bulk_actions_search' |
265 | 265 | ) |
266 | 266 | ), |
267 | - 'help_tour' => array( 'Venues_Overview_Help_Tour' ), |
|
267 | + 'help_tour' => array('Venues_Overview_Help_Tour'), |
|
268 | 268 | 'metaboxes' => array('_espresso_news_post_box', '_espresso_links_post_box'), |
269 | 269 | 'require_nonce' => FALSE |
270 | 270 | ), |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | 'filename' => 'venues_editor_other' |
301 | 301 | ) |
302 | 302 | ), |
303 | - 'help_tour' => array( 'Venues_Add_Venue_Help_Tour' ), |
|
303 | + 'help_tour' => array('Venues_Add_Venue_Help_Tour'), |
|
304 | 304 | 'metaboxes' => array('_venue_editor_metaboxes'), |
305 | 305 | 'require_nonce' => FALSE |
306 | 306 | ), |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | 'label' => __('Edit Venue', 'event_espresso'), |
310 | 310 | 'order' => 5, |
311 | 311 | 'persistent' => FALSE, |
312 | - 'url' => isset($this->_req_data['post']) ? add_query_arg(array('post' => $this->_req_data['post'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
312 | + 'url' => isset($this->_req_data['post']) ? add_query_arg(array('post' => $this->_req_data['post']), $this->_current_page_view_url) : $this->_admin_base_url |
|
313 | 313 | ), |
314 | 314 | 'help_tabs' => array( |
315 | 315 | 'venues_editor_help_tab' => array( |
@@ -346,14 +346,14 @@ discard block |
||
346 | 346 | 'label' => __('Google Maps'), |
347 | 347 | 'order' => 40 |
348 | 348 | ), |
349 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
349 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
350 | 350 | 'help_tabs' => array( |
351 | 351 | 'general_settings_google_maps_help_tab' => array( |
352 | 352 | 'title' => __('Google Maps', 'event_espresso'), |
353 | 353 | 'filename' => 'general_settings_google_maps' |
354 | 354 | ) |
355 | 355 | ), |
356 | - 'help_tour' => array( 'Google_Maps_Help_Tour' ), |
|
356 | + 'help_tour' => array('Google_Maps_Help_Tour'), |
|
357 | 357 | 'require_nonce' => FALSE |
358 | 358 | ), |
359 | 359 | //venue category stuff |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | 'filename' => 'venues_add_category' |
370 | 370 | ) |
371 | 371 | ), |
372 | - 'help_tour' => array( 'Venues_Add_Category_Help_Tour' ), |
|
372 | + 'help_tour' => array('Venues_Add_Category_Help_Tour'), |
|
373 | 373 | 'require_nonce' => FALSE |
374 | 374 | ), |
375 | 375 | 'edit_category' => array( |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | 'label' => __('Edit Category', 'event_espresso'), |
378 | 378 | 'order' => 15, |
379 | 379 | 'persistent' => FALSE, |
380 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
380 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
381 | 381 | ), |
382 | 382 | 'metaboxes' => array('_publish_post_box'), |
383 | 383 | 'help_tabs' => array( |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | 'filename' => 'venues_categories_other' |
414 | 414 | ) |
415 | 415 | ), |
416 | - 'help_tour' => array( 'Venues_Categories_Help_Tour' ), |
|
416 | + 'help_tour' => array('Venues_Categories_Help_Tour'), |
|
417 | 417 | 'metaboxes' => $this->_default_espresso_metaboxes, |
418 | 418 | 'require_nonce' => FALSE |
419 | 419 | ) |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | |
471 | 471 | |
472 | 472 | public function load_scripts_styles() { |
473 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
473 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
474 | 474 | wp_enqueue_style('ee-cat-admin'); |
475 | 475 | } |
476 | 476 | |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | public function load_scripts_styles_edit() { |
494 | 494 | //styles |
495 | 495 | wp_enqueue_style('espresso-ui-theme'); |
496 | - wp_register_style( 'espresso_venues', EE_VENUES_ASSETS_URL . 'ee-venues-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
496 | + wp_register_style('espresso_venues', EE_VENUES_ASSETS_URL.'ee-venues-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
497 | 497 | wp_enqueue_style('espresso_venues'); |
498 | 498 | } |
499 | 499 | |
@@ -512,13 +512,13 @@ discard block |
||
512 | 512 | ) |
513 | 513 | ); |
514 | 514 | |
515 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_venues', 'espresso_venues_trash_venues' ) ) { |
|
515 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) { |
|
516 | 516 | $this->_views['all']['bulk_action'] = array( |
517 | 517 | 'trash_venues' => __('Move to Trash', 'event_espresso') |
518 | 518 | ); |
519 | 519 | $this->_views['trash'] = array( |
520 | 520 | 'slug' => 'trash', |
521 | - 'label' => __( 'Trash', 'event_espresso' ), |
|
521 | + 'label' => __('Trash', 'event_espresso'), |
|
522 | 522 | 'count' => 0, |
523 | 523 | 'bulk_action' => array( |
524 | 524 | 'restore_venues' => __('Restore from Trash', 'event_espresso'), |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | |
552 | 552 | |
553 | 553 | protected function _overview_list_table() { |
554 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
555 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_venues'), __("View Venue Archive Page", "event_espresso"), 'button' ); |
|
554 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
555 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_venues'), __("View Venue Archive Page", "event_espresso"), 'button'); |
|
556 | 556 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
557 | 557 | $this->_search_btn_label = __('Venues', 'event_espresso'); |
558 | 558 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -566,8 +566,8 @@ discard block |
||
566 | 566 | 'vnu_url' => $this->_cpt_model_obj->venue_url(), |
567 | 567 | 'vnu_phone' => $this->_cpt_model_obj->phone() |
568 | 568 | ); |
569 | - $template = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php'; |
|
570 | - EEH_Template::display_template( $template, $extra_rows ); |
|
569 | + $template = EE_VENUES_TEMPLATE_PATH.'venue_publish_box_extras.template.php'; |
|
570 | + EEH_Template::display_template($template, $extra_rows); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | |
@@ -583,31 +583,31 @@ discard block |
||
583 | 583 | $default_map_settings->use_google_maps = TRUE; |
584 | 584 | $default_map_settings->google_map_api_key = ''; |
585 | 585 | // for event details pages (reg page) |
586 | - $default_map_settings->event_details_map_width = 585; // ee_map_width_single |
|
587 | - $default_map_settings->event_details_map_height = 362; // ee_map_height_single |
|
588 | - $default_map_settings->event_details_map_zoom = 14; // ee_map_zoom_single |
|
589 | - $default_map_settings->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
590 | - $default_map_settings->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
591 | - $default_map_settings->event_details_control_type = 'default'; // ee_map_type_control_single |
|
592 | - $default_map_settings->event_details_map_align = 'center'; // ee_map_align_single |
|
586 | + $default_map_settings->event_details_map_width = 585; // ee_map_width_single |
|
587 | + $default_map_settings->event_details_map_height = 362; // ee_map_height_single |
|
588 | + $default_map_settings->event_details_map_zoom = 14; // ee_map_zoom_single |
|
589 | + $default_map_settings->event_details_display_nav = TRUE; // ee_map_nav_display_single |
|
590 | + $default_map_settings->event_details_nav_size = FALSE; // ee_map_nav_size_single |
|
591 | + $default_map_settings->event_details_control_type = 'default'; // ee_map_type_control_single |
|
592 | + $default_map_settings->event_details_map_align = 'center'; // ee_map_align_single |
|
593 | 593 | // for event list pages |
594 | - $default_map_settings->event_list_map_width = 300; // ee_map_width |
|
595 | - $default_map_settings->event_list_map_height = 185; // ee_map_height |
|
596 | - $default_map_settings->event_list_map_zoom = 12; // ee_map_zoom |
|
597 | - $default_map_settings->event_list_display_nav = FALSE; // ee_map_nav_display |
|
598 | - $default_map_settings->event_list_nav_size = TRUE; // ee_map_nav_size |
|
599 | - $default_map_settings->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
600 | - $default_map_settings->event_list_map_align = 'center'; // ee_map_align |
|
594 | + $default_map_settings->event_list_map_width = 300; // ee_map_width |
|
595 | + $default_map_settings->event_list_map_height = 185; // ee_map_height |
|
596 | + $default_map_settings->event_list_map_zoom = 12; // ee_map_zoom |
|
597 | + $default_map_settings->event_list_display_nav = FALSE; // ee_map_nav_display |
|
598 | + $default_map_settings->event_list_nav_size = TRUE; // ee_map_nav_size |
|
599 | + $default_map_settings->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
600 | + $default_map_settings->event_list_map_align = 'center'; // ee_map_align |
|
601 | 601 | |
602 | 602 | $this->_template_args['map_settings'] = |
603 | - isset( EE_Registry::instance()->CFG->map_settings ) && ! empty( EE_Registry::instance()->CFG->map_settings ) |
|
604 | - ? (object)array_merge( (array)$default_map_settings, (array)EE_Registry::instance()->CFG->map_settings ) |
|
603 | + isset(EE_Registry::instance()->CFG->map_settings) && ! empty(EE_Registry::instance()->CFG->map_settings) |
|
604 | + ? (object) array_merge((array) $default_map_settings, (array) EE_Registry::instance()->CFG->map_settings) |
|
605 | 605 | : $default_map_settings; |
606 | 606 | |
607 | - $this->_set_add_edit_form_tags( 'update_google_map_settings' ); |
|
608 | - $this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
|
607 | + $this->_set_add_edit_form_tags('update_google_map_settings'); |
|
608 | + $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
|
609 | 609 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
610 | - EE_VENUES_TEMPLATE_PATH . 'google_map.template.php', |
|
610 | + EE_VENUES_TEMPLATE_PATH.'google_map.template.php', |
|
611 | 611 | $this->_template_args, |
612 | 612 | true |
613 | 613 | ); |
@@ -617,83 +617,83 @@ discard block |
||
617 | 617 | protected function _update_google_map_settings() { |
618 | 618 | |
619 | 619 | EE_Registry::instance()->CFG->map_settings->use_google_maps = |
620 | - isset( $this->_req_data['use_google_maps'] ) |
|
621 | - ? absint( $this->_req_data['use_google_maps'] ) |
|
620 | + isset($this->_req_data['use_google_maps']) |
|
621 | + ? absint($this->_req_data['use_google_maps']) |
|
622 | 622 | : EE_Registry::instance()->CFG->map_settings->use_google_maps; |
623 | 623 | |
624 | 624 | EE_Registry::instance()->CFG->map_settings->google_map_api_key = |
625 | - isset( $this->_req_data['google_map_api_key'] ) |
|
626 | - ? sanitize_text_field( $this->_req_data['google_map_api_key'] ) |
|
625 | + isset($this->_req_data['google_map_api_key']) |
|
626 | + ? sanitize_text_field($this->_req_data['google_map_api_key']) |
|
627 | 627 | : EE_Registry::instance()->CFG->map_settings->google_map_api_key; |
628 | 628 | |
629 | 629 | EE_Registry::instance()->CFG->map_settings->event_details_map_width = |
630 | - isset( $this->_req_data['event_details_map_width'] ) |
|
631 | - ? absint( $this->_req_data['event_details_map_width'] ) |
|
630 | + isset($this->_req_data['event_details_map_width']) |
|
631 | + ? absint($this->_req_data['event_details_map_width']) |
|
632 | 632 | : EE_Registry::instance()->CFG->map_settings->event_details_map_width; |
633 | 633 | |
634 | 634 | EE_Registry::instance()->CFG->map_settings->event_details_map_height = |
635 | - isset( $this->_req_data['event_details_map_height'] ) |
|
636 | - ? absint( $this->_req_data['event_details_map_height'] ) |
|
635 | + isset($this->_req_data['event_details_map_height']) |
|
636 | + ? absint($this->_req_data['event_details_map_height']) |
|
637 | 637 | : EE_Registry::instance()->CFG->map_settings->event_details_map_height; |
638 | 638 | |
639 | 639 | EE_Registry::instance()->CFG->map_settings->event_details_map_zoom = |
640 | - isset( $this->_req_data['event_details_map_zoom'] ) |
|
641 | - ? absint( $this->_req_data['event_details_map_zoom'] ) |
|
640 | + isset($this->_req_data['event_details_map_zoom']) |
|
641 | + ? absint($this->_req_data['event_details_map_zoom']) |
|
642 | 642 | : EE_Registry::instance()->CFG->map_settings->event_details_map_zoom; |
643 | 643 | |
644 | 644 | EE_Registry::instance()->CFG->map_settings->event_details_display_nav = |
645 | - isset( $this->_req_data['event_details_display_nav'] ) |
|
646 | - ? absint( $this->_req_data['event_details_display_nav'] ) |
|
645 | + isset($this->_req_data['event_details_display_nav']) |
|
646 | + ? absint($this->_req_data['event_details_display_nav']) |
|
647 | 647 | : EE_Registry::instance()->CFG->map_settings->event_details_display_nav; |
648 | 648 | |
649 | 649 | EE_Registry::instance()->CFG->map_settings->event_details_nav_size = |
650 | - isset( $this->_req_data['event_details_nav_size'] ) |
|
651 | - ? absint( $this->_req_data['event_details_nav_size'] ) |
|
650 | + isset($this->_req_data['event_details_nav_size']) |
|
651 | + ? absint($this->_req_data['event_details_nav_size']) |
|
652 | 652 | : EE_Registry::instance()->CFG->map_settings->event_details_nav_size; |
653 | 653 | |
654 | 654 | EE_Registry::instance()->CFG->map_settings->event_details_control_type = |
655 | - isset( $this->_req_data['event_details_control_type'] ) |
|
656 | - ? sanitize_text_field( $this->_req_data['event_details_control_type'] ) |
|
655 | + isset($this->_req_data['event_details_control_type']) |
|
656 | + ? sanitize_text_field($this->_req_data['event_details_control_type']) |
|
657 | 657 | : EE_Registry::instance()->CFG->map_settings->event_details_control_type; |
658 | 658 | |
659 | 659 | EE_Registry::instance()->CFG->map_settings->event_details_map_align = |
660 | - isset( $this->_req_data['event_details_map_align'] ) |
|
661 | - ? sanitize_text_field( $this->_req_data['event_details_map_align'] ) |
|
660 | + isset($this->_req_data['event_details_map_align']) |
|
661 | + ? sanitize_text_field($this->_req_data['event_details_map_align']) |
|
662 | 662 | : EE_Registry::instance()->CFG->map_settings->event_details_map_align; |
663 | 663 | |
664 | 664 | EE_Registry::instance()->CFG->map_settings->event_list_map_width = |
665 | - isset( $this->_req_data['event_list_map_width'] ) |
|
666 | - ? absint( $this->_req_data['event_list_map_width'] ) |
|
665 | + isset($this->_req_data['event_list_map_width']) |
|
666 | + ? absint($this->_req_data['event_list_map_width']) |
|
667 | 667 | : EE_Registry::instance()->CFG->map_settings->event_list_map_width; |
668 | 668 | |
669 | 669 | EE_Registry::instance()->CFG->map_settings->event_list_map_height = |
670 | - isset( $this->_req_data['event_list_map_height'] ) |
|
671 | - ? absint( $this->_req_data['event_list_map_height'] ) |
|
670 | + isset($this->_req_data['event_list_map_height']) |
|
671 | + ? absint($this->_req_data['event_list_map_height']) |
|
672 | 672 | : EE_Registry::instance()->CFG->map_settings->event_list_map_height; |
673 | 673 | |
674 | 674 | EE_Registry::instance()->CFG->map_settings->event_list_map_zoom = |
675 | - isset( $this->_req_data['event_list_map_zoom'] ) |
|
676 | - ? absint( $this->_req_data['event_list_map_zoom'] ) |
|
675 | + isset($this->_req_data['event_list_map_zoom']) |
|
676 | + ? absint($this->_req_data['event_list_map_zoom']) |
|
677 | 677 | : EE_Registry::instance()->CFG->map_settings->event_list_map_zoom; |
678 | 678 | |
679 | 679 | EE_Registry::instance()->CFG->map_settings->event_list_display_nav = |
680 | - isset( $this->_req_data['event_list_display_nav'] ) |
|
681 | - ? absint( $this->_req_data['event_list_display_nav'] ) |
|
680 | + isset($this->_req_data['event_list_display_nav']) |
|
681 | + ? absint($this->_req_data['event_list_display_nav']) |
|
682 | 682 | : EE_Registry::instance()->CFG->map_settings->event_list_display_nav; |
683 | 683 | |
684 | 684 | EE_Registry::instance()->CFG->map_settings->event_list_nav_size = |
685 | - isset( $this->_req_data['event_list_nav_size'] ) |
|
686 | - ? absint( $this->_req_data['event_list_nav_size'] ) |
|
685 | + isset($this->_req_data['event_list_nav_size']) |
|
686 | + ? absint($this->_req_data['event_list_nav_size']) |
|
687 | 687 | : EE_Registry::instance()->CFG->map_settings->event_list_nav_size; |
688 | 688 | |
689 | 689 | EE_Registry::instance()->CFG->map_settings->event_list_control_type = |
690 | - isset( $this->_req_data['event_list_control_type'] ) |
|
691 | - ? sanitize_text_field( $this->_req_data['event_list_control_type'] ) |
|
690 | + isset($this->_req_data['event_list_control_type']) |
|
691 | + ? sanitize_text_field($this->_req_data['event_list_control_type']) |
|
692 | 692 | : EE_Registry::instance()->CFG->map_settings->event_list_control_type; |
693 | 693 | |
694 | 694 | EE_Registry::instance()->CFG->map_settings->event_list_map_align = |
695 | - isset( $this->_req_data['event_list_map_align'] ) |
|
696 | - ? sanitize_text_field( $this->_req_data['event_list_map_align'] ) |
|
695 | + isset($this->_req_data['event_list_map_align']) |
|
696 | + ? sanitize_text_field($this->_req_data['event_list_map_align']) |
|
697 | 697 | : EE_Registry::instance()->CFG->map_settings->event_list_map_align; |
698 | 698 | |
699 | 699 | EE_Registry::instance()->CFG->map_settings = apply_filters( |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | EE_Registry::instance()->CFG->map_settings, |
708 | 708 | __FILE__, __FUNCTION__, __LINE__ |
709 | 709 | ); |
710 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'google_map_settings' ) ); |
|
710 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'google_map_settings')); |
|
711 | 711 | |
712 | 712 | } |
713 | 713 | |
@@ -716,9 +716,9 @@ discard block |
||
716 | 716 | protected function _venue_editor_metaboxes() { |
717 | 717 | $this->verify_cpt_object(); |
718 | 718 | |
719 | - add_meta_box( 'espresso_venue_address_options', __('Physical Location', 'event_espresso'), array( $this, 'venue_address_metabox'), $this->page_slug, 'side', 'default' ); |
|
720 | - add_meta_box( 'espresso_venue_gmap_options', __('Google Map', 'event_espresso'), array( $this, 'venue_gmap_metabox'), $this->page_slug, 'side', 'default' ); |
|
721 | - add_meta_box( 'espresso_venue_virtual_loc_options', __('Virtual Location', 'event_espresso'), array( $this, 'venue_virtual_loc_metabox'), $this->page_slug, 'side', 'default' ); |
|
719 | + add_meta_box('espresso_venue_address_options', __('Physical Location', 'event_espresso'), array($this, 'venue_address_metabox'), $this->page_slug, 'side', 'default'); |
|
720 | + add_meta_box('espresso_venue_gmap_options', __('Google Map', 'event_espresso'), array($this, 'venue_gmap_metabox'), $this->page_slug, 'side', 'default'); |
|
721 | + add_meta_box('espresso_venue_virtual_loc_options', __('Virtual Location', 'event_espresso'), array($this, 'venue_virtual_loc_metabox'), $this->page_slug, 'side', 'default'); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
@@ -726,23 +726,23 @@ discard block |
||
726 | 726 | |
727 | 727 | public function venue_gmap_metabox() { |
728 | 728 | $template_args = array( |
729 | - 'vnu_enable_for_gmap' => EEH_Form_Fields::select_input('vnu_enable_for_gmap', $this->get_yes_no_values(), $this->_cpt_model_obj->enable_for_gmap() ), |
|
729 | + 'vnu_enable_for_gmap' => EEH_Form_Fields::select_input('vnu_enable_for_gmap', $this->get_yes_no_values(), $this->_cpt_model_obj->enable_for_gmap()), |
|
730 | 730 | 'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(), |
731 | 731 | ); |
732 | - $template = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php'; |
|
733 | - EEH_Template::display_template( $template, $template_args ); |
|
732 | + $template = EE_VENUES_TEMPLATE_PATH.'venue_gmap_metabox_content.template.php'; |
|
733 | + EEH_Template::display_template($template, $template_args); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | |
737 | 737 | |
738 | 738 | public function venue_address_metabox() { |
739 | 739 | |
740 | - $template_args['_venue'] =$this->_cpt_model_obj; |
|
740 | + $template_args['_venue'] = $this->_cpt_model_obj; |
|
741 | 741 | |
742 | 742 | $template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input( |
743 | 743 | $QFI = new EE_Question_Form_Input( |
744 | - EE_Question::new_instance( array( 'QST_display_text' => 'State', 'QST_system' => 'state' )), |
|
745 | - EE_Answer::new_instance( array( 'ANS_value'=> $this->_cpt_model_obj->state_ID() )), |
|
744 | + EE_Question::new_instance(array('QST_display_text' => 'State', 'QST_system' => 'state')), |
|
745 | + EE_Answer::new_instance(array('ANS_value'=> $this->_cpt_model_obj->state_ID())), |
|
746 | 746 | array( |
747 | 747 | 'input_name' => 'sta_id', |
748 | 748 | 'input_id' => 'sta_id', |
@@ -754,8 +754,8 @@ discard block |
||
754 | 754 | ); |
755 | 755 | $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input( |
756 | 756 | $QFI = new EE_Question_Form_Input( |
757 | - EE_Question::new_instance( array( 'QST_display_text' => 'Country', 'QST_system' => 'country' )), |
|
758 | - EE_Answer::new_instance( array( 'ANS_value'=> $this->_cpt_model_obj->country_ID() )), |
|
757 | + EE_Question::new_instance(array('QST_display_text' => 'Country', 'QST_system' => 'country')), |
|
758 | + EE_Answer::new_instance(array('ANS_value'=> $this->_cpt_model_obj->country_ID())), |
|
759 | 759 | array( |
760 | 760 | 'input_name' => 'cnt_iso', |
761 | 761 | 'input_id' => 'cnt_iso', |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | ) |
767 | 767 | ); |
768 | 768 | |
769 | - $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php'; |
|
770 | - EEH_Template::display_template( $template, $template_args ); |
|
769 | + $template = EE_VENUES_TEMPLATE_PATH.'venue_address_metabox_content.template.php'; |
|
770 | + EEH_Template::display_template($template, $template_args); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | |
@@ -779,8 +779,8 @@ discard block |
||
779 | 779 | $template_args = array( |
780 | 780 | '_venue' => $this->_cpt_model_obj |
781 | 781 | ); |
782 | - $template = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php'; |
|
783 | - EEH_Template::display_template( $template, $template_args ); |
|
782 | + $template = EE_VENUES_TEMPLATE_PATH.'venue_virtual_location_metabox_content.template.php'; |
|
783 | + EEH_Template::display_template($template, $template_args); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
@@ -803,52 +803,52 @@ discard block |
||
803 | 803 | * @param object $post Post object (with "blessed" WP properties) |
804 | 804 | * @return void |
805 | 805 | */ |
806 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
806 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
807 | 807 | |
808 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_venues' ) { |
|
809 | - return;// get out we're not processing the saving of venues. |
|
808 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') { |
|
809 | + return; // get out we're not processing the saving of venues. |
|
810 | 810 | } |
811 | 811 | |
812 | - $wheres = array( $this->_venue_model->primary_key_name() => $post_id ); |
|
812 | + $wheres = array($this->_venue_model->primary_key_name() => $post_id); |
|
813 | 813 | |
814 | 814 | $venue_values = array( |
815 | - 'VNU_address' => !empty( $this->_req_data['vnu_address'] ) ? $this->_req_data['vnu_address'] : NULL, |
|
816 | - 'VNU_address2' => !empty( $this->_req_data['vnu_address2'] ) ? $this->_req_data['vnu_address2'] : NULL, |
|
817 | - 'VNU_city' => !empty( $this->_req_data['vnu_city'] ) ? $this->_req_data['vnu_city'] : NULL, |
|
818 | - 'STA_ID' => !empty( $this->_req_data['sta_id'] ) ? $this->_req_data['sta_id'] : NULL, |
|
819 | - 'CNT_ISO' => !empty( $this->_req_data['cnt_iso'] ) ? $this->_req_data['cnt_iso'] : NULL, |
|
820 | - 'VNU_zip' => !empty( $this->_req_data['vnu_zip'] ) ? $this->_req_data['vnu_zip'] : NULL, |
|
821 | - 'VNU_phone' => !empty( $this->_req_data['vnu_phone'] ) ? $this->_req_data['vnu_phone'] : NULL, |
|
822 | - 'VNU_capacity' => !empty( $this->_req_data['vnu_capacity'] ) ? str_replace( ',', '', $this->_req_data['vnu_capacity'] ) : EE_INF, |
|
823 | - 'VNU_url' => !empty( $this->_req_data['vnu_url'] ) ? $this->_req_data['vnu_url'] : NULL, |
|
824 | - 'VNU_virtual_phone' => !empty( $this->_req_data['vnu_virtual_phone'] ) ? $this->_req_data['vnu_virtual_phone'] : NULL, |
|
825 | - 'VNU_virtual_url' => !empty( $this->_req_data['vnu_virtual_url'] ) ? $this->_req_data['vnu_virtual_url'] : NULL, |
|
826 | - 'VNU_enable_for_gmap' => !empty( $this->_req_data['vnu_enable_for_gmap'] ) ? TRUE : FALSE, |
|
827 | - 'VNU_google_map_link' => !empty( $this->_req_data['vnu_google_map_link'] ) ? $this->_req_data['vnu_google_map_link'] : NULL |
|
815 | + 'VNU_address' => ! empty($this->_req_data['vnu_address']) ? $this->_req_data['vnu_address'] : NULL, |
|
816 | + 'VNU_address2' => ! empty($this->_req_data['vnu_address2']) ? $this->_req_data['vnu_address2'] : NULL, |
|
817 | + 'VNU_city' => ! empty($this->_req_data['vnu_city']) ? $this->_req_data['vnu_city'] : NULL, |
|
818 | + 'STA_ID' => ! empty($this->_req_data['sta_id']) ? $this->_req_data['sta_id'] : NULL, |
|
819 | + 'CNT_ISO' => ! empty($this->_req_data['cnt_iso']) ? $this->_req_data['cnt_iso'] : NULL, |
|
820 | + 'VNU_zip' => ! empty($this->_req_data['vnu_zip']) ? $this->_req_data['vnu_zip'] : NULL, |
|
821 | + 'VNU_phone' => ! empty($this->_req_data['vnu_phone']) ? $this->_req_data['vnu_phone'] : NULL, |
|
822 | + 'VNU_capacity' => ! empty($this->_req_data['vnu_capacity']) ? str_replace(',', '', $this->_req_data['vnu_capacity']) : EE_INF, |
|
823 | + 'VNU_url' => ! empty($this->_req_data['vnu_url']) ? $this->_req_data['vnu_url'] : NULL, |
|
824 | + 'VNU_virtual_phone' => ! empty($this->_req_data['vnu_virtual_phone']) ? $this->_req_data['vnu_virtual_phone'] : NULL, |
|
825 | + 'VNU_virtual_url' => ! empty($this->_req_data['vnu_virtual_url']) ? $this->_req_data['vnu_virtual_url'] : NULL, |
|
826 | + 'VNU_enable_for_gmap' => ! empty($this->_req_data['vnu_enable_for_gmap']) ? TRUE : FALSE, |
|
827 | + 'VNU_google_map_link' => ! empty($this->_req_data['vnu_google_map_link']) ? $this->_req_data['vnu_google_map_link'] : NULL |
|
828 | 828 | ); |
829 | 829 | |
830 | 830 | //update venue |
831 | - $success = $this->_venue_model->update( $venue_values, array( $wheres ) ); |
|
831 | + $success = $this->_venue_model->update($venue_values, array($wheres)); |
|
832 | 832 | |
833 | 833 | //get venue_object for other metaboxes that might be added via the filter... though it would seem to make sense to just use $this->_venue_model->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
834 | - $get_one_where = array( $this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
835 | - $venue = $this->_venue_model->get_one( array( $get_one_where ) ); |
|
834 | + $get_one_where = array($this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
835 | + $venue = $this->_venue_model->get_one(array($get_one_where)); |
|
836 | 836 | |
837 | 837 | //notice we've applied a filter for venue metabox callbacks but we don't actually have any default venue metaboxes in use. So this is just here for addons to more easily hook into venue saves. |
838 | - $venue_update_callbacks = apply_filters( 'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks', array() ); |
|
838 | + $venue_update_callbacks = apply_filters('FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks', array()); |
|
839 | 839 | |
840 | 840 | $att_success = TRUE; |
841 | 841 | |
842 | - foreach ( $venue_update_callbacks as $v_callback ) { |
|
843 | - $_succ = call_user_func_array( $v_callback, array( $venue, $this->_req_data ) ); |
|
844 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
842 | + foreach ($venue_update_callbacks as $v_callback) { |
|
843 | + $_succ = call_user_func_array($v_callback, array($venue, $this->_req_data)); |
|
844 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | //any errors? |
848 | - if ( $success && !$att_success ) { |
|
849 | - EE_Error::add_error( __('Venue Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
850 | - } else if ( $success === FALSE ) { |
|
851 | - EE_Error::add_error( __('Venue Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
848 | + if ($success && ! $att_success) { |
|
849 | + EE_Error::add_error(__('Venue Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
850 | + } else if ($success === FALSE) { |
|
851 | + EE_Error::add_error(__('Venue Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
852 | 852 | } |
853 | 853 | } |
854 | 854 | |
@@ -856,9 +856,9 @@ discard block |
||
856 | 856 | |
857 | 857 | |
858 | 858 | |
859 | - public function trash_cpt_item( $post_id ) { |
|
859 | + public function trash_cpt_item($post_id) { |
|
860 | 860 | $this->_req_data['VNU_ID'] = $post_id; |
861 | - $this->_trash_or_restore_venue( 'trash', FALSE ); |
|
861 | + $this->_trash_or_restore_venue('trash', FALSE); |
|
862 | 862 | } |
863 | 863 | |
864 | 864 | |
@@ -866,18 +866,18 @@ discard block |
||
866 | 866 | |
867 | 867 | |
868 | 868 | |
869 | - public function restore_cpt_item( $post_id ) { |
|
869 | + public function restore_cpt_item($post_id) { |
|
870 | 870 | $this->_req_data['VNU_ID'] = $post_id; |
871 | - $this->_trash_or_restore_venue( 'draft', FALSE ); |
|
871 | + $this->_trash_or_restore_venue('draft', FALSE); |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | |
875 | 875 | |
876 | 876 | |
877 | 877 | |
878 | - public function delete_cpt_item( $post_id ) { |
|
878 | + public function delete_cpt_item($post_id) { |
|
879 | 879 | $this->_req_data['VNU_ID'] = $post_id; |
880 | - $this->_delete_venue( FALSE ); |
|
880 | + $this->_delete_venue(FALSE); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | |
@@ -892,15 +892,15 @@ discard block |
||
892 | 892 | |
893 | 893 | |
894 | 894 | |
895 | - protected function _trash_or_restore_venue( $venue_status = 'trash', $redirect_after = TRUE ) { |
|
896 | - $VNU_ID = isset( $this->_req_data['VNU_ID'] ) ? absint( $this->_req_data['VNU_ID'] ) : FALSE; |
|
895 | + protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = TRUE) { |
|
896 | + $VNU_ID = isset($this->_req_data['VNU_ID']) ? absint($this->_req_data['VNU_ID']) : FALSE; |
|
897 | 897 | |
898 | 898 | //loop thru venues |
899 | - if ( $VNU_ID ) { |
|
899 | + if ($VNU_ID) { |
|
900 | 900 | //clean status |
901 | - $venue_status = sanitize_key( $venue_status ); |
|
901 | + $venue_status = sanitize_key($venue_status); |
|
902 | 902 | // grab status |
903 | - if (!empty($venue_status)) { |
|
903 | + if ( ! empty($venue_status)) { |
|
904 | 904 | $success = $this->_change_venue_status($VNU_ID, $venue_status); |
905 | 905 | } else { |
906 | 906 | $success = FALSE; |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | } |
915 | 915 | $action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
916 | 916 | |
917 | - if ( $redirect_after ) |
|
917 | + if ($redirect_after) |
|
918 | 918 | $this->_redirect_after_action($success, 'Venue', $action, array('action' => 'default')); |
919 | 919 | |
920 | 920 | } |
@@ -923,11 +923,11 @@ discard block |
||
923 | 923 | |
924 | 924 | |
925 | 925 | |
926 | - protected function _trash_or_restore_venues( $venue_status = 'trash' ) { |
|
926 | + protected function _trash_or_restore_venues($venue_status = 'trash') { |
|
927 | 927 | // clean status |
928 | 928 | $venue_status = sanitize_key($venue_status); |
929 | 929 | // grab status |
930 | - if (!empty($venue_status)) { |
|
930 | + if ( ! empty($venue_status)) { |
|
931 | 931 | $success = TRUE; |
932 | 932 | //determine the event id and set to array. |
933 | 933 | $VNU_IDs = isset($this->_req_data['venue_id']) ? (array) $this->_req_data['venue_id'] : array(); |
@@ -967,20 +967,20 @@ discard block |
||
967 | 967 | * @param string $venue_status |
968 | 968 | * @return void |
969 | 969 | */ |
970 | - private function _change_venue_status( $VNU_ID = 0, $venue_status = '' ) { |
|
970 | + private function _change_venue_status($VNU_ID = 0, $venue_status = '') { |
|
971 | 971 | // grab venue id |
972 | - if (! $VNU_ID) { |
|
972 | + if ( ! $VNU_ID) { |
|
973 | 973 | $msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso'); |
974 | 974 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
975 | 975 | return FALSE; |
976 | 976 | } |
977 | 977 | |
978 | - $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID( $VNU_ID ); |
|
978 | + $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
979 | 979 | |
980 | 980 | // clean status |
981 | 981 | $venue_status = sanitize_key($venue_status); |
982 | 982 | // grab status |
983 | - if ( ! $venue_status ) { |
|
983 | + if ( ! $venue_status) { |
|
984 | 984 | $msg = __('An error occurred. No Venue Status or an invalid Venue Status was received.', 'event_espresso'); |
985 | 985 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
986 | 986 | return FALSE; |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | $hook = FALSE; |
1002 | 1002 | } |
1003 | 1003 | //use class to change status |
1004 | - $this->_cpt_model_obj->set_status( $venue_status ); |
|
1004 | + $this->_cpt_model_obj->set_status($venue_status); |
|
1005 | 1005 | $success = $this->_cpt_model_obj->save(); |
1006 | 1006 | |
1007 | 1007 | if ($success === FALSE) { |
@@ -1020,21 +1020,21 @@ discard block |
||
1020 | 1020 | * @param bool $redirect_after |
1021 | 1021 | * @return void |
1022 | 1022 | */ |
1023 | - protected function _delete_venue( $redirect_after = true ) { |
|
1023 | + protected function _delete_venue($redirect_after = true) { |
|
1024 | 1024 | //determine the venue id and set to array. |
1025 | 1025 | $VNU_ID = isset($this->_req_data['VNU_ID']) ? absint($this->_req_data['VNU_ID']) : NULL; |
1026 | - $VNU_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $VNU_ID; |
|
1026 | + $VNU_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $VNU_ID; |
|
1027 | 1027 | |
1028 | 1028 | |
1029 | 1029 | // loop thru venues |
1030 | 1030 | if ($VNU_ID) { |
1031 | - $success = $this->_delete_or_trash_venue( $VNU_ID ); |
|
1031 | + $success = $this->_delete_or_trash_venue($VNU_ID); |
|
1032 | 1032 | } else { |
1033 | 1033 | $success = FALSE; |
1034 | 1034 | $msg = __('An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.', 'event_espresso'); |
1035 | 1035 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1036 | 1036 | } |
1037 | - if ( $redirect_after ) |
|
1037 | + if ($redirect_after) |
|
1038 | 1038 | $this->_redirect_after_action($success, 'Venue', 'deleted', array('action' => 'default')); |
1039 | 1039 | } |
1040 | 1040 | |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | //todo: put in parent |
1067 | 1067 | private function _delete_or_trash_venue($VNU_ID = FALSE) { |
1068 | 1068 | // grab event id |
1069 | - if (!$VNU_ID = absint($VNU_ID)) { |
|
1069 | + if ( ! $VNU_ID = absint($VNU_ID)) { |
|
1070 | 1070 | $msg = __('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso'); |
1071 | 1071 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1072 | 1072 | return FALSE; |
@@ -1086,7 +1086,7 @@ discard block |
||
1086 | 1086 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1087 | 1087 | return FALSE; |
1088 | 1088 | } |
1089 | - do_action( 'AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted' ); |
|
1089 | + do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted'); |
|
1090 | 1090 | return TRUE; |
1091 | 1091 | } |
1092 | 1092 | |
@@ -1097,11 +1097,11 @@ discard block |
||
1097 | 1097 | /* QUERIES */ |
1098 | 1098 | |
1099 | 1099 | |
1100 | - public function get_venues( $per_page = 10, $count = FALSE ) { |
|
1100 | + public function get_venues($per_page = 10, $count = FALSE) { |
|
1101 | 1101 | |
1102 | - $_orderby = !empty( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : ''; |
|
1102 | + $_orderby = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
|
1103 | 1103 | |
1104 | - switch ( $_orderby ) { |
|
1104 | + switch ($_orderby) { |
|
1105 | 1105 | case 'id': |
1106 | 1106 | $orderby = 'VNU_ID'; |
1107 | 1107 | break; |
@@ -1119,43 +1119,43 @@ discard block |
||
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | |
1122 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
1122 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
1123 | 1123 | |
1124 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1125 | - $per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10; |
|
1126 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1124 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1125 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
1126 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1127 | 1127 | |
1128 | 1128 | |
1129 | - $offset = ($current_page-1)*$per_page; |
|
1129 | + $offset = ($current_page - 1) * $per_page; |
|
1130 | 1130 | $limit = array($offset, $per_page); |
1131 | 1131 | |
1132 | - $category = isset( $this->_req_data['category'] ) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL; |
|
1132 | + $category = isset($this->_req_data['category']) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL; |
|
1133 | 1133 | $where = array(); |
1134 | 1134 | |
1135 | 1135 | //only set initial status if it is in the incoming request. Otherwise the "all" view display's all statuses. |
1136 | - if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] != 'all' ) { |
|
1136 | + if (isset($this->_req_data['status']) && $this->_req_data['status'] != 'all') { |
|
1137 | 1137 | $where['status'] = $this->_req_data['status']; |
1138 | 1138 | } |
1139 | 1139 | |
1140 | - if ( isset( $this->_req_data['venue_status'] ) ) { |
|
1140 | + if (isset($this->_req_data['venue_status'])) { |
|
1141 | 1141 | $where['status'] = $this->_req_data['venue_status']; |
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | |
1145 | - if ( $category ) { |
|
1145 | + if ($category) { |
|
1146 | 1146 | $where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories'; |
1147 | 1147 | $where['Term_Taxonomy.term_id'] = $category; |
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | |
1151 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_venues', 'get_venues' ) ) { |
|
1152 | - $where['VNU_wp_user'] = get_current_user_id(); |
|
1151 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
1152 | + $where['VNU_wp_user'] = get_current_user_id(); |
|
1153 | 1153 | } else { |
1154 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' ) ) { |
|
1154 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
1155 | 1155 | $where['OR'] = array( |
1156 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1156 | + 'status*restrict_private' => array('!=', 'private'), |
|
1157 | 1157 | 'AND' => array( |
1158 | - 'status*inclusive' => array( '=', 'private' ), |
|
1158 | + 'status*inclusive' => array('=', 'private'), |
|
1159 | 1159 | 'VNU_wp_user' => get_current_user_id() |
1160 | 1160 | ) |
1161 | 1161 | ); |
@@ -1165,30 +1165,30 @@ discard block |
||
1165 | 1165 | |
1166 | 1166 | |
1167 | 1167 | |
1168 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1169 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1168 | + if (isset($this->_req_data['s'])) { |
|
1169 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1170 | 1170 | $where['OR'] = array( |
1171 | - 'VNU_name' => array('LIKE',$sstr ), |
|
1172 | - 'VNU_desc' => array('LIKE',$sstr ), |
|
1173 | - 'VNU_short_desc' => array( 'LIKE',$sstr ), |
|
1174 | - 'VNU_address' => array( 'LIKE', $sstr ), |
|
1175 | - 'VNU_address2' => array( 'LIKE', $sstr ), |
|
1176 | - 'VNU_city' => array( 'LIKE', $sstr ), |
|
1177 | - 'VNU_zip' => array( 'LIKE', $sstr ), |
|
1178 | - 'VNU_phone' => array( 'LIKE', $sstr ), |
|
1179 | - 'VNU_url' => array( 'LIKE', $sstr ), |
|
1180 | - 'VNU_virtual_phone' => array( 'LIKE', $sstr ), |
|
1181 | - 'VNU_virtual_url' => array( 'LIKE', $sstr ), |
|
1182 | - 'VNU_google_map_link' => array( 'LIKE', $sstr ), |
|
1183 | - 'Event.EVT_name' => array('LIKE', $sstr ), |
|
1184 | - 'Event.EVT_desc' => array('LIKE', $sstr ), |
|
1185 | - 'Event.EVT_phone' => array('LIKE', $sstr ), |
|
1186 | - 'Event.EVT_external_URL' => array('LIKE', $sstr ), |
|
1171 | + 'VNU_name' => array('LIKE', $sstr), |
|
1172 | + 'VNU_desc' => array('LIKE', $sstr), |
|
1173 | + 'VNU_short_desc' => array('LIKE', $sstr), |
|
1174 | + 'VNU_address' => array('LIKE', $sstr), |
|
1175 | + 'VNU_address2' => array('LIKE', $sstr), |
|
1176 | + 'VNU_city' => array('LIKE', $sstr), |
|
1177 | + 'VNU_zip' => array('LIKE', $sstr), |
|
1178 | + 'VNU_phone' => array('LIKE', $sstr), |
|
1179 | + 'VNU_url' => array('LIKE', $sstr), |
|
1180 | + 'VNU_virtual_phone' => array('LIKE', $sstr), |
|
1181 | + 'VNU_virtual_url' => array('LIKE', $sstr), |
|
1182 | + 'VNU_google_map_link' => array('LIKE', $sstr), |
|
1183 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
1184 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
1185 | + 'Event.EVT_phone' => array('LIKE', $sstr), |
|
1186 | + 'Event.EVT_external_URL' => array('LIKE', $sstr), |
|
1187 | 1187 | ); |
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | |
1191 | - $venues = $count ? $this->_venue_model->count( array($where), 'VNU_ID' ) : $this->_venue_model->get_all( array( $where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort ) ); |
|
1191 | + $venues = $count ? $this->_venue_model->count(array($where), 'VNU_ID') : $this->_venue_model->get_all(array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort)); |
|
1192 | 1192 | |
1193 | 1193 | return $venues; |
1194 | 1194 | |
@@ -1206,22 +1206,22 @@ discard block |
||
1206 | 1206 | * @return void |
1207 | 1207 | */ |
1208 | 1208 | private function _set_category_object() { |
1209 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
1209 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
1210 | 1210 | return; //already have the category object so get out. |
1211 | 1211 | |
1212 | 1212 | //set default category object |
1213 | 1213 | $this->_set_empty_category_object(); |
1214 | 1214 | |
1215 | 1215 | //only set if we've got an id |
1216 | - if ( !isset($this->_req_data['VEN_CAT_ID'] ) ) { |
|
1216 | + if ( ! isset($this->_req_data['VEN_CAT_ID'])) { |
|
1217 | 1217 | return; |
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | $category_id = absint($this->_req_data['VEN_CAT_ID']); |
1221 | - $term = get_term( $category_id, 'espresso_venue_categories' ); |
|
1221 | + $term = get_term($category_id, 'espresso_venue_categories'); |
|
1222 | 1222 | |
1223 | 1223 | |
1224 | - if ( !empty( $term ) ) { |
|
1224 | + if ( ! empty($term)) { |
|
1225 | 1225 | $this->_category->category_name = $term->name; |
1226 | 1226 | $this->_category->category_identifier = $term->slug; |
1227 | 1227 | $this->_category->category_desc = $term->description; |
@@ -1235,14 +1235,14 @@ discard block |
||
1235 | 1235 | |
1236 | 1236 | private function _set_empty_category_object() { |
1237 | 1237 | $this->_category = new stdClass(); |
1238 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
1238 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
1239 | 1239 | $this->_category->id = $this->_category->parent = 0; |
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | |
1243 | 1243 | |
1244 | 1244 | protected function _category_list_table() { |
1245 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1245 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1246 | 1246 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
1247 | 1247 | $this->_search_btn_label = __('Venue Categories', 'event_espresso'); |
1248 | 1248 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -1258,13 +1258,13 @@ discard block |
||
1258 | 1258 | $this->_set_add_edit_form_tags($route); |
1259 | 1259 | |
1260 | 1260 | $this->_set_category_object(); |
1261 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
1261 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
1262 | 1262 | |
1263 | 1263 | $delete_action = 'delete_category'; |
1264 | 1264 | |
1265 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'category_list' ), $this->_admin_base_url ); |
|
1265 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
1266 | 1266 | |
1267 | - $this->_set_publish_post_box_vars( 'VEN_CAT_ID', $id, $delete_action, $redirect ); |
|
1267 | + $this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect); |
|
1268 | 1268 | |
1269 | 1269 | //take care of contents |
1270 | 1270 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -1278,25 +1278,25 @@ discard block |
||
1278 | 1278 | 'type' => 'wp_editor', |
1279 | 1279 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
1280 | 1280 | 'class' => 'my_editor_custom', |
1281 | - 'wpeditor_args' => array( 'media_buttons' => FALSE ) |
|
1281 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
1282 | 1282 | ); |
1283 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
1283 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
1284 | 1284 | |
1285 | - $all_terms = get_terms( array('espresso_venue_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
1285 | + $all_terms = get_terms(array('espresso_venue_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
1286 | 1286 | |
1287 | 1287 | //setup category select for term parents. |
1288 | 1288 | $category_select_values[] = array( |
1289 | 1289 | 'text' => __('No Parent', 'event_espresso'), |
1290 | 1290 | 'id' => 0 |
1291 | 1291 | ); |
1292 | - foreach ( $all_terms as $term ) { |
|
1292 | + foreach ($all_terms as $term) { |
|
1293 | 1293 | $category_select_values[] = array( |
1294 | 1294 | 'text' => $term->name, |
1295 | 1295 | 'id' => $term->term_id |
1296 | 1296 | ); |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
1299 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
1300 | 1300 | $template_args = array( |
1301 | 1301 | 'category' => $this->_category, |
1302 | 1302 | 'category_select' => $category_select, |
@@ -1305,15 +1305,15 @@ discard block |
||
1305 | 1305 | 'disable' => '', |
1306 | 1306 | 'disabled_message' =>FALSE |
1307 | 1307 | ); |
1308 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
1309 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
1308 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
1309 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1310 | 1310 | } |
1311 | 1311 | |
1312 | 1312 | |
1313 | 1313 | protected function _delete_categories() { |
1314 | - $cat_ids = isset( $this->_req_data['VEN_CAT_ID'] ) ? (array) $this->_req_data['VEN_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
1314 | + $cat_ids = isset($this->_req_data['VEN_CAT_ID']) ? (array) $this->_req_data['VEN_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
1315 | 1315 | |
1316 | - foreach ( $cat_ids as $cat_id ) { |
|
1316 | + foreach ($cat_ids as $cat_id) { |
|
1317 | 1317 | $this->_delete_category($cat_id); |
1318 | 1318 | } |
1319 | 1319 | |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | $query_args = array( |
1322 | 1322 | 'action' => 'category_list' |
1323 | 1323 | ); |
1324 | - $this->_redirect_after_action(0,'','',$query_args); |
|
1324 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
1325 | 1325 | |
1326 | 1326 | } |
1327 | 1327 | |
@@ -1330,58 +1330,58 @@ discard block |
||
1330 | 1330 | |
1331 | 1331 | |
1332 | 1332 | protected function _delete_category($cat_id) { |
1333 | - $cat_id = absint( $cat_id ); |
|
1334 | - wp_delete_term( $cat_id, 'espresso_venue_categories' ); |
|
1333 | + $cat_id = absint($cat_id); |
|
1334 | + wp_delete_term($cat_id, 'espresso_venue_categories'); |
|
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | |
1338 | 1338 | |
1339 | 1339 | protected function _insert_or_update_category($new_category) { |
1340 | 1340 | |
1341 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
1341 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
1342 | 1342 | $success = 0; //we already have a success message so lets not send another. |
1343 | - if ( $cat_id ) { |
|
1343 | + if ($cat_id) { |
|
1344 | 1344 | $query_args = array( |
1345 | 1345 | 'action' => 'edit_category', |
1346 | 1346 | 'VEN_CAT_ID' => $cat_id |
1347 | 1347 | ); |
1348 | 1348 | } else { |
1349 | - $query_args = array( 'action' => 'add_category' ); |
|
1349 | + $query_args = array('action' => 'add_category'); |
|
1350 | 1350 | } |
1351 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
1351 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
1352 | 1352 | |
1353 | 1353 | } |
1354 | 1354 | |
1355 | 1355 | |
1356 | 1356 | |
1357 | - private function _insert_category( $update = FALSE ) { |
|
1357 | + private function _insert_category($update = FALSE) { |
|
1358 | 1358 | $cat_id = $update ? $this->_req_data['VEN_CAT_ID'] : ''; |
1359 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
1360 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
1361 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
1359 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
1360 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
1361 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
1362 | 1362 | |
1363 | - if ( empty( $category_name ) ) { |
|
1364 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
1365 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1363 | + if (empty($category_name)) { |
|
1364 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
1365 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1366 | 1366 | return false; |
1367 | 1367 | } |
1368 | 1368 | |
1369 | 1369 | |
1370 | - $term_args=array( |
|
1370 | + $term_args = array( |
|
1371 | 1371 | 'name'=>$category_name, |
1372 | 1372 | 'description'=>$category_desc, |
1373 | 1373 | 'parent'=>$category_parent |
1374 | 1374 | ); |
1375 | 1375 | |
1376 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_venue_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_venue_categories', $term_args ); |
|
1376 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_venue_categories', $term_args) : wp_insert_term($category_name, 'espresso_venue_categories', $term_args); |
|
1377 | 1377 | |
1378 | - if ( !is_array( $insert_ids ) ) { |
|
1379 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
1380 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1378 | + if ( ! is_array($insert_ids)) { |
|
1379 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
1380 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1381 | 1381 | } else { |
1382 | 1382 | $cat_id = $insert_ids['term_id']; |
1383 | - $msg = sprintf ( __('The category %s was successfully created', 'event_espresso'), $category_name ); |
|
1384 | - EE_Error::add_success( $msg ); |
|
1383 | + $msg = sprintf(__('The category %s was successfully created', 'event_espresso'), $category_name); |
|
1384 | + EE_Error::add_success($msg); |
|
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | return $cat_id; |
@@ -1401,11 +1401,11 @@ discard block |
||
1401 | 1401 | 'category_ids' => $this->_req_data['VEN_CAT_ID'] |
1402 | 1402 | ); |
1403 | 1403 | |
1404 | - $this->_req_data = array_merge( $this->_req_data, $new_request_args ); |
|
1404 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
1405 | 1405 | |
1406 | - if ( is_readable( EE_CLASSES . 'EE_Export.class.php') ) { |
|
1407 | - require_once( EE_CLASSES . 'EE_Export.class.php'); |
|
1408 | - $EE_Export = EE_Export::instance( $this->_req_data ); |
|
1406 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
1407 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
1408 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
1409 | 1409 | $EE_Export->export(); |
1410 | 1410 | } |
1411 | 1411 | |
@@ -1417,7 +1417,7 @@ discard block |
||
1417 | 1417 | |
1418 | 1418 | protected function _import_categories() { |
1419 | 1419 | |
1420 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
1420 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
1421 | 1421 | EE_Import::instance()->import(); |
1422 | 1422 | |
1423 | 1423 | } |
@@ -1425,29 +1425,29 @@ discard block |
||
1425 | 1425 | |
1426 | 1426 | |
1427 | 1427 | |
1428 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
1428 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
1429 | 1429 | |
1430 | 1430 | //testing term stuff |
1431 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
1432 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
1433 | - $limit = ($current_page-1)*$per_page; |
|
1434 | - $where = array( 'taxonomy' => 'espresso_venue_categories' ); |
|
1435 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1436 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1431 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
1432 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
1433 | + $limit = ($current_page - 1) * $per_page; |
|
1434 | + $where = array('taxonomy' => 'espresso_venue_categories'); |
|
1435 | + if (isset($this->_req_data['s'])) { |
|
1436 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1437 | 1437 | $where['OR'] = array( |
1438 | - 'Term.name' => array( 'LIKE', $sstr), |
|
1439 | - 'description' => array( 'LIKE', $sstr ) |
|
1438 | + 'Term.name' => array('LIKE', $sstr), |
|
1439 | + 'description' => array('LIKE', $sstr) |
|
1440 | 1440 | ); |
1441 | 1441 | } |
1442 | 1442 | |
1443 | 1443 | $query_params = array( |
1444 | 1444 | $where, |
1445 | - 'order_by' => array( $orderby => $order ), |
|
1446 | - 'limit' => $limit . ',' . $per_page, |
|
1445 | + 'order_by' => array($orderby => $order), |
|
1446 | + 'limit' => $limit.','.$per_page, |
|
1447 | 1447 | 'force_join' => array('Term') |
1448 | 1448 | ); |
1449 | 1449 | |
1450 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
1450 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
1451 | 1451 | |
1452 | 1452 | return $categories; |
1453 | 1453 | } |