@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | // if you're a dev and want to receive all errors via email add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE ); |
3 | -if ( defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE && defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS === TRUE ) { |
|
4 | - set_error_handler( array( 'EE_Error', 'error_handler' )); |
|
5 | - register_shutdown_function( array( 'EE_Error', 'fatal_error_handler' )); |
|
3 | +if (defined('WP_DEBUG') && WP_DEBUG === TRUE && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === TRUE) { |
|
4 | + set_error_handler(array('EE_Error', 'error_handler')); |
|
5 | + register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
6 | 6 | } |
7 | 7 | /** |
8 | 8 | * |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @access private |
65 | 65 | * @var boolean |
66 | 66 | */ |
67 | - private static $_espresso_notices = array( 'success' => FALSE, 'errors' => FALSE, 'attention' => FALSE ); |
|
67 | + private static $_espresso_notices = array('success' => FALSE, 'errors' => FALSE, 'attention' => FALSE); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @access public |
76 | 76 | * @echo string |
77 | 77 | */ |
78 | - function __construct( $message, $code = 0, Exception $previous = NULL ) { |
|
79 | - if ( version_compare( phpversion(), '5.3.0', '<' )) { |
|
80 | - parent::__construct( $message, $code ); |
|
78 | + function __construct($message, $code = 0, Exception $previous = NULL) { |
|
79 | + if (version_compare(phpversion(), '5.3.0', '<')) { |
|
80 | + parent::__construct($message, $code); |
|
81 | 81 | } else { |
82 | - parent::__construct( $message, $code, $previous ); |
|
82 | + parent::__construct($message, $code, $previous); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | * @param $line |
95 | 95 | * @return void |
96 | 96 | */ |
97 | - public static function error_handler( $code, $message, $file, $line ) { |
|
98 | - $type = EE_Error::error_type( $code ); |
|
97 | + public static function error_handler($code, $message, $file, $line) { |
|
98 | + $type = EE_Error::error_type($code); |
|
99 | 99 | $site = site_url(); |
100 | - switch ( $site ) { |
|
100 | + switch ($site) { |
|
101 | 101 | case 'http://ee4.eventespresso.com/' : |
102 | 102 | case 'http://ee4decaf.eventespresso.com/' : |
103 | 103 | case 'http://ee4hf.eventespresso.com/' : |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | $to = '[email protected]'; |
111 | 111 | break; |
112 | 112 | default : |
113 | - $to = get_option( 'admin_email' ); |
|
113 | + $to = get_option('admin_email'); |
|
114 | 114 | } |
115 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
116 | - $msg = EE_Error::_format_error( $type, $message, $file, $line ); |
|
117 | - if ( function_exists( 'wp_mail' )) { |
|
118 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
119 | - wp_mail( $to, $subject, $msg ); |
|
115 | + $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url(); |
|
116 | + $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
117 | + if (function_exists('wp_mail')) { |
|
118 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
119 | + wp_mail($to, $subject, $msg); |
|
120 | 120 | } |
121 | 121 | echo '<div id="message" class="espresso-notices error"><p>'; |
122 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
122 | + echo $type.': '.$message.'<br />'.$file.' line '.$line; |
|
123 | 123 | echo '<br /></p></div>'; |
124 | 124 | } |
125 | 125 | |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param $code |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public static function error_type( $code ) { |
|
136 | - switch( $code ) { |
|
135 | + public static function error_type($code) { |
|
136 | + switch ($code) { |
|
137 | 137 | case E_ERROR: // 1 // |
138 | 138 | return 'E_ERROR'; |
139 | 139 | case E_WARNING: // 2 // |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function fatal_error_handler() { |
181 | 181 | $last_error = error_get_last(); |
182 | - if ( $last_error['type'] === E_ERROR ) { |
|
183 | - EE_Error::error_handler( E_ERROR, $last_error['message'], $last_error['file'], $last_error['line'] ); |
|
182 | + if ($last_error['type'] === E_ERROR) { |
|
183 | + EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param $line |
196 | 196 | * @return string |
197 | 197 | */ |
198 | - private static function _format_error( $code, $message, $file, $line ) { |
|
198 | + private static function _format_error($code, $message, $file, $line) { |
|
199 | 199 | $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
200 | 200 | $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
201 | 201 | $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @param $content_type |
214 | 214 | * @return string |
215 | 215 | */ |
216 | - public static function set_content_type( $content_type ) { |
|
216 | + public static function set_content_type($content_type) { |
|
217 | 217 | return 'text/html'; |
218 | 218 | } |
219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function get_error() { |
229 | 229 | |
230 | - if( apply_filters( 'FHEE__EE_Error__get_error__show_normal_exceptions', FALSE ) ){ |
|
230 | + if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', FALSE)) { |
|
231 | 231 | throw $this; |
232 | 232 | } |
233 | 233 | // get separate user and developer messages if they exist |
234 | - $msg = explode( '||', $this->getMessage() ); |
|
234 | + $msg = explode('||', $this->getMessage()); |
|
235 | 235 | $user_msg = $msg[0]; |
236 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
236 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
237 | 237 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
238 | 238 | |
239 | 239 | // add details to _all_exceptions array |
240 | 240 | $x_time = time(); |
241 | - self::$_all_exceptions[ $x_time ]['name'] = get_class( $this ); |
|
242 | - self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
243 | - self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
244 | - self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
245 | - self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
246 | - self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
247 | - self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
241 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
242 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
243 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
244 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
245 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
246 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
247 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
248 | 248 | self::$_error_count++; |
249 | 249 | |
250 | 250 | //add_action( 'shutdown', array( $this, 'display_errors' )); |
@@ -262,14 +262,14 @@ discard block |
||
262 | 262 | * @param string $type_to_check |
263 | 263 | * @return bool |
264 | 264 | */ |
265 | - public static function has_error( $check_stored = false, $type_to_check = 'errors' ){ |
|
265 | + public static function has_error($check_stored = false, $type_to_check = 'errors') { |
|
266 | 266 | $has_error = isset(self::$_espresso_notices[$type_to_check]) && ! empty(self::$_espresso_notices[$type_to_check]) |
267 | 267 | ? true |
268 | 268 | : false; |
269 | - if ( $check_stored && ! $has_error ) { |
|
270 | - $notices = (array) get_option( 'ee_notices', array() ); |
|
271 | - foreach ( $notices as $type => $notice ) { |
|
272 | - if ( $type === $type_to_check && $notice ) { |
|
269 | + if ($check_stored && ! $has_error) { |
|
270 | + $notices = (array) get_option('ee_notices', array()); |
|
271 | + foreach ($notices as $type => $notice) { |
|
272 | + if ($type === $type_to_check && $notice) { |
|
273 | 273 | return true; |
274 | 274 | } |
275 | 275 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @access public |
285 | 285 | * @echo string |
286 | 286 | */ |
287 | - public function display_errors(){ |
|
287 | + public function display_errors() { |
|
288 | 288 | |
289 | 289 | $trace_details = ''; |
290 | 290 | |
@@ -345,18 +345,18 @@ discard block |
||
345 | 345 | </style> |
346 | 346 | <div id="ee-error-message" class="error">'; |
347 | 347 | |
348 | - if ( ! WP_DEBUG ) { |
|
348 | + if ( ! WP_DEBUG) { |
|
349 | 349 | $output .= ' |
350 | 350 | <p>'; |
351 | 351 | } |
352 | 352 | |
353 | 353 | // cycle thru errors |
354 | - foreach ( self::$_all_exceptions as $time => $ex ) { |
|
354 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
355 | 355 | |
356 | 356 | // process trace info |
357 | - if ( empty( $ex['trace'] )) { |
|
357 | + if (empty($ex['trace'])) { |
|
358 | 358 | |
359 | - $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' ); |
|
359 | + $trace_details .= __('Sorry, but no trace information was available for this exception.', 'event_espresso'); |
|
360 | 360 | |
361 | 361 | } else { |
362 | 362 | |
@@ -371,50 +371,50 @@ discard block |
||
371 | 371 | <th scope="col" align="left">Method( arguments )</th> |
372 | 372 | </tr>'; |
373 | 373 | |
374 | - $last_on_stack = count( $ex['trace'] ) - 1; |
|
374 | + $last_on_stack = count($ex['trace']) - 1; |
|
375 | 375 | // reverse array so that stack is in proper chronological order |
376 | - $sorted_trace = array_reverse( $ex['trace'] ); |
|
376 | + $sorted_trace = array_reverse($ex['trace']); |
|
377 | 377 | |
378 | - foreach ( $sorted_trace as $nmbr => $trace ) { |
|
378 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
379 | 379 | |
380 | - $file = isset( $trace['file'] ) ? $trace['file'] : '' ; |
|
381 | - $class = isset( $trace['class'] ) ? $trace['class'] : ''; |
|
382 | - $type = isset( $trace['type'] ) ? $trace['type'] : ''; |
|
383 | - $function = isset( $trace['function'] ) ? $trace['function'] : ''; |
|
384 | - $args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : ''; |
|
385 | - $line = isset( $trace['line'] ) ? $trace['line'] : ''; |
|
380 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
381 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
382 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
383 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
384 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
385 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
386 | 386 | $zebra = $nmbr % 2 ? ' odd' : ''; |
387 | 387 | |
388 | - if ( empty( $file ) && ! empty( $class )) { |
|
389 | - $a = new ReflectionClass( $class ); |
|
388 | + if (empty($file) && ! empty($class)) { |
|
389 | + $a = new ReflectionClass($class); |
|
390 | 390 | $file = $a->getFileName(); |
391 | - if ( empty( $line ) && ! empty( $function )) { |
|
392 | - $b = new ReflectionMethod( $class, $function ); |
|
391 | + if (empty($line) && ! empty($function)) { |
|
392 | + $b = new ReflectionMethod($class, $function); |
|
393 | 393 | $line = $b->getStartLine(); |
394 | 394 | } |
395 | 395 | } |
396 | 396 | |
397 | - if ( $nmbr == $last_on_stack ) { |
|
397 | + if ($nmbr == $last_on_stack) { |
|
398 | 398 | $file = $ex['file'] != '' ? $ex['file'] : $file; |
399 | 399 | $line = $ex['line'] != '' ? $ex['line'] : $line; |
400 | - $error_code = self::generate_error_code ( $file, $trace['function'], $line ); |
|
400 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
401 | 401 | } |
402 | 402 | |
403 | - $nmbr_dsply = ! empty( $nmbr ) ? $nmbr : ' '; |
|
404 | - $line_dsply = ! empty( $line ) ? $line : ' '; |
|
405 | - $file_dsply = ! empty( $file ) ? $file : ' '; |
|
406 | - $class_dsply = ! empty( $class ) ? $class : ' '; |
|
407 | - $type_dsply = ! empty( $type ) ? $type : ' '; |
|
408 | - $function_dsply = ! empty( $function ) ? $function : ' '; |
|
409 | - $args_dsply = ! empty( $args ) ? '( ' . $args . ' )' : ''; |
|
403 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
404 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
405 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
406 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
407 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
408 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
409 | + $args_dsply = ! empty($args) ? '( '.$args.' )' : ''; |
|
410 | 410 | |
411 | 411 | $trace_details .= ' |
412 | 412 | <tr> |
413 | - <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
|
414 | - <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
|
415 | - <td align="left" class="' . $zebra . '">' . $file_dsply . '</td> |
|
416 | - <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
|
417 | - <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
|
413 | + <td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td> |
|
414 | + <td align="right" class="' . $zebra.'">'.$line_dsply.'</td> |
|
415 | + <td align="left" class="' . $zebra.'">'.$file_dsply.'</td> |
|
416 | + <td align="left" class="' . $zebra.'">'.$class_dsply.'</td> |
|
417 | + <td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td> |
|
418 | 418 | </tr>'; |
419 | 419 | |
420 | 420 | |
@@ -429,9 +429,9 @@ discard block |
||
429 | 429 | $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
430 | 430 | |
431 | 431 | // add generic non-identifying messages for non-privileged uesrs |
432 | - if ( ! WP_DEBUG ) { |
|
432 | + if ( ! WP_DEBUG) { |
|
433 | 433 | |
434 | - $output .= '<span class="ee-error-user-msg-spn">' . trim( $ex['msg'] ) . '</span> <sup>' . $ex['code'] . '</sup><br />'; |
|
434 | + $output .= '<span class="ee-error-user-msg-spn">'.trim($ex['msg']).'</span> <sup>'.$ex['code'].'</sup><br />'; |
|
435 | 435 | |
436 | 436 | } else { |
437 | 437 | |
@@ -439,24 +439,24 @@ discard block |
||
439 | 439 | $output .= ' |
440 | 440 | <div class="ee-error-dev-msg-dv"> |
441 | 441 | <p class="ee-error-dev-msg-pg"> |
442 | - <strong class="ee-error-dev-msg-str">An ' . $ex['name'] . ' exception was thrown!</strong> <span>code: ' . $ex['code'] . '</span><br /> |
|
443 | - <span class="big-text">"' . trim( $ex['msg'] ) . '"</span><br/> |
|
444 | - <a id="display-ee-error-trace-' . self::$_error_count . $time . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' . self::$_error_count . $time . '"> |
|
445 | - ' . __( 'click to view backtrace and class/method details', 'event_espresso' ) . ' |
|
442 | + <strong class="ee-error-dev-msg-str">An ' . $ex['name'].' exception was thrown!</strong> <span>code: '.$ex['code'].'</span><br /> |
|
443 | + <span class="big-text">"' . trim($ex['msg']).'"</span><br/> |
|
444 | + <a id="display-ee-error-trace-' . self::$_error_count.$time.'" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'.self::$_error_count.$time.'"> |
|
445 | + ' . __('click to view backtrace and class/method details', 'event_espresso').' |
|
446 | 446 | </a><br /> |
447 | 447 | <span class="small-text lt-grey-text">'.$ex['file'].' ( line no: '.$ex['line'].' )</span> |
448 | 448 | </p> |
449 | - <div id="ee-error-trace-' . self::$_error_count . $time . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
449 | + <div id="ee-error-trace-' . self::$_error_count.$time.'-dv" class="ee-error-trace-dv" style="display: none;"> |
|
450 | 450 | ' . $trace_details; |
451 | 451 | |
452 | - if ( ! empty( $class )) { |
|
452 | + if ( ! empty($class)) { |
|
453 | 453 | $output .= ' |
454 | 454 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
455 | 455 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
456 | 456 | <h3>Class Details</h3>'; |
457 | - $a = new ReflectionClass( $class ); |
|
457 | + $a = new ReflectionClass($class); |
|
458 | 458 | $output .= ' |
459 | - <pre>' . $a . '</pre> |
|
459 | + <pre>' . $a.'</pre> |
|
460 | 460 | </div> |
461 | 461 | </div>'; |
462 | 462 | } |
@@ -468,14 +468,14 @@ discard block |
||
468 | 468 | |
469 | 469 | } |
470 | 470 | |
471 | - $this->write_to_error_log( $time, $ex ); |
|
471 | + $this->write_to_error_log($time, $ex); |
|
472 | 472 | |
473 | 473 | } |
474 | 474 | |
475 | 475 | // remove last linebreak |
476 | - $output = substr( $output, 0, ( count( $output ) - 7 )); |
|
476 | + $output = substr($output, 0, (count($output) - 7)); |
|
477 | 477 | |
478 | - if ( ! WP_DEBUG ) { |
|
478 | + if ( ! WP_DEBUG) { |
|
479 | 479 | $output .= ' |
480 | 480 | </p>'; |
481 | 481 | } |
@@ -483,10 +483,10 @@ discard block |
||
483 | 483 | $output .= ' |
484 | 484 | </div>'; |
485 | 485 | |
486 | - $output .= self::_print_scripts( TRUE ); |
|
486 | + $output .= self::_print_scripts(TRUE); |
|
487 | 487 | |
488 | - if ( defined( 'DOING_AJAX' )) { |
|
489 | - echo wp_json_encode( array( 'error' => $output )); |
|
488 | + if (defined('DOING_AJAX')) { |
|
489 | + echo wp_json_encode(array('error' => $output)); |
|
490 | 490 | exit(); |
491 | 491 | } |
492 | 492 | |
@@ -506,29 +506,29 @@ discard block |
||
506 | 506 | * @ param array $arguments |
507 | 507 | * @ return string |
508 | 508 | */ |
509 | - private function _convert_args_to_string ( $arguments = array(), $array = FALSE ) { |
|
509 | + private function _convert_args_to_string($arguments = array(), $array = FALSE) { |
|
510 | 510 | |
511 | 511 | $arg_string = ''; |
512 | - if ( ! empty( $arguments )) { |
|
512 | + if ( ! empty($arguments)) { |
|
513 | 513 | |
514 | 514 | $args = array(); |
515 | 515 | |
516 | - foreach ( $arguments as $arg ) { |
|
516 | + foreach ($arguments as $arg) { |
|
517 | 517 | |
518 | - if ( ! empty( $arg )) { |
|
518 | + if ( ! empty($arg)) { |
|
519 | 519 | |
520 | - if ( is_string( $arg )) { |
|
521 | - $args[] = " '" . $arg . "'"; |
|
522 | - } elseif ( is_array( $arg )) { |
|
523 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string( $arg, TRUE ); |
|
524 | - } elseif ( is_null( $arg )) { |
|
520 | + if (is_string($arg)) { |
|
521 | + $args[] = " '".$arg."'"; |
|
522 | + } elseif (is_array($arg)) { |
|
523 | + $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, TRUE); |
|
524 | + } elseif (is_null($arg)) { |
|
525 | 525 | $args[] = ' NULL'; |
526 | - } elseif ( is_bool( $arg )) { |
|
527 | - $args[] = ( $arg ) ? ' TRUE' : ' FALSE'; |
|
528 | - } elseif ( is_object( $arg )) { |
|
529 | - $args[] = ' OBJECT ' . get_class( $arg ); |
|
530 | - } elseif ( is_resource( $arg )) { |
|
531 | - $args[] = get_resource_type( $arg ); |
|
526 | + } elseif (is_bool($arg)) { |
|
527 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
528 | + } elseif (is_object($arg)) { |
|
529 | + $args[] = ' OBJECT '.get_class($arg); |
|
530 | + } elseif (is_resource($arg)) { |
|
531 | + $args[] = get_resource_type($arg); |
|
532 | 532 | } else { |
533 | 533 | $args[] = $arg; |
534 | 534 | } |
@@ -536,9 +536,9 @@ discard block |
||
536 | 536 | } |
537 | 537 | |
538 | 538 | } |
539 | - $arg_string = implode( ', ', $args ); |
|
539 | + $arg_string = implode(', ', $args); |
|
540 | 540 | } |
541 | - if ( $array ) { |
|
541 | + if ($array) { |
|
542 | 542 | $arg_string .= ' )'; |
543 | 543 | } |
544 | 544 | return $arg_string; |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | * @param string $line the line number where the error occurred - just use __LINE__ |
559 | 559 | * @return void |
560 | 560 | */ |
561 | - public static function add_error( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
562 | - self::_add_notice ( 'errors', $msg, $file, $func, $line ); |
|
561 | + public static function add_error($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
562 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
563 | 563 | self::$_error_count++; |
564 | 564 | } |
565 | 565 | |
@@ -572,11 +572,11 @@ discard block |
||
572 | 572 | * @param string $line |
573 | 573 | * @throws EE_Error |
574 | 574 | */ |
575 | - public static function throw_exception_if_debugging( $msg = null, $file = null, $func = null, $line = null ) { |
|
576 | - if( WP_DEBUG ) { |
|
577 | - throw new EE_Error( $msg ); |
|
578 | - } else { |
|
579 | - EE_Error::add_error( $msg, $file, $func, $line ); |
|
575 | + public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) { |
|
576 | + if (WP_DEBUG) { |
|
577 | + throw new EE_Error($msg); |
|
578 | + } else { |
|
579 | + EE_Error::add_error($msg, $file, $func, $line); |
|
580 | 580 | } |
581 | 581 | } |
582 | 582 | |
@@ -594,8 +594,8 @@ discard block |
||
594 | 594 | * @param string $line the line number where the error occurred - just use __LINE__ |
595 | 595 | * @return void |
596 | 596 | */ |
597 | - public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
598 | - self::_add_notice ( 'success', $msg, $file, $func, $line ); |
|
597 | + public static function add_success($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
598 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | |
@@ -612,8 +612,8 @@ discard block |
||
612 | 612 | * @param string $line the line number where the error occurred - just use __LINE__ |
613 | 613 | * @return void |
614 | 614 | */ |
615 | - public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
616 | - self::_add_notice ( 'attention', $msg, $file, $func, $line ); |
|
615 | + public static function add_attention($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
616 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | |
@@ -631,12 +631,12 @@ discard block |
||
631 | 631 | * @param string $line the line number where the error occurred - just use __LINE__ |
632 | 632 | * @return void |
633 | 633 | */ |
634 | - private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
635 | - if ( empty( $msg )) { |
|
634 | + private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
635 | + if (empty($msg)) { |
|
636 | 636 | EE_Error::doing_it_wrong( |
637 | - 'EE_Error::add_' . $type . '()', |
|
637 | + 'EE_Error::add_'.$type.'()', |
|
638 | 638 | sprintf( |
639 | - __( 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso' ), |
|
639 | + __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso'), |
|
640 | 640 | $type, |
641 | 641 | $file, |
642 | 642 | $line |
@@ -644,17 +644,17 @@ discard block |
||
644 | 644 | EVENT_ESPRESSO_VERSION |
645 | 645 | ); |
646 | 646 | } |
647 | - if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) { |
|
647 | + if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
648 | 648 | EE_Error::doing_it_wrong( |
649 | 649 | 'EE_Error::add_error()', |
650 | - __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso' ), |
|
650 | + __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso'), |
|
651 | 651 | EVENT_ESPRESSO_VERSION |
652 | 652 | ); |
653 | 653 | } |
654 | 654 | // get separate user and developer messages if they exist |
655 | - $msg = explode( '||', $msg ); |
|
655 | + $msg = explode('||', $msg); |
|
656 | 656 | $user_msg = $msg[0]; |
657 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
657 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
658 | 658 | /** |
659 | 659 | * Do an action so other code can be triggered when a notice is created |
660 | 660 | * @param string $type can be 'errors', 'attention', or 'success' |
@@ -664,22 +664,22 @@ discard block |
||
664 | 664 | * @param string $func function where error was generated |
665 | 665 | * @param string $line line where error was generated |
666 | 666 | */ |
667 | - do_action( 'AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line ); |
|
667 | + do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line); |
|
668 | 668 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
669 | 669 | // add notice if message exists |
670 | - if ( ! empty( $msg )) { |
|
670 | + if ( ! empty($msg)) { |
|
671 | 671 | // get error code |
672 | - $notice_code = EE_Error::generate_error_code( $file, $func, $line ); |
|
673 | - if ( WP_DEBUG && $type == 'errors' ) { |
|
674 | - $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
672 | + $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
673 | + if (WP_DEBUG && $type == 'errors') { |
|
674 | + $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>'; |
|
675 | 675 | } |
676 | 676 | // add notice. Index by code if it's not blank |
677 | - if( $notice_code ) { |
|
678 | - self::$_espresso_notices[ $type ][ $notice_code ] = $msg; |
|
677 | + if ($notice_code) { |
|
678 | + self::$_espresso_notices[$type][$notice_code] = $msg; |
|
679 | 679 | } else { |
680 | - self::$_espresso_notices[ $type ][] = $msg; |
|
680 | + self::$_espresso_notices[$type][] = $msg; |
|
681 | 681 | } |
682 | - add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 ); |
|
682 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | } |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | * @access private |
734 | 734 | * @return void |
735 | 735 | */ |
736 | - public static function reset_notices(){ |
|
736 | + public static function reset_notices() { |
|
737 | 737 | self::$_espresso_notices['success'] = FALSE; |
738 | 738 | self::$_espresso_notices['attention'] = FALSE; |
739 | 739 | self::$_espresso_notices['errors'] = FALSE; |
@@ -746,14 +746,14 @@ discard block |
||
746 | 746 | * @access public |
747 | 747 | * @return int |
748 | 748 | */ |
749 | - public static function has_notices(){ |
|
749 | + public static function has_notices() { |
|
750 | 750 | $has_notices = 0; |
751 | 751 | // check for success messages |
752 | - $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
|
752 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices; |
|
753 | 753 | // check for attention messages |
754 | - $has_notices = self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ? 2 : $has_notices; |
|
754 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices; |
|
755 | 755 | // check for error messages |
756 | - $has_notices = self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ? 1 : $has_notices; |
|
756 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices; |
|
757 | 757 | return $has_notices; |
758 | 758 | } |
759 | 759 | |
@@ -768,9 +768,9 @@ discard block |
||
768 | 768 | */ |
769 | 769 | public static function get_vanilla_notices() { |
770 | 770 | return array( |
771 | - 'success' => isset( self::$_espresso_notices['success'] ) ? self::$_espresso_notices['success'] : array(), |
|
772 | - 'attention' => isset( self::$_espresso_notices['attention'] ) ? self::$_espresso_notices['attention'] : array(), |
|
773 | - 'errors' => isset( self::$_espresso_notices['errors'] ) ? self::$_espresso_notices['errors'] : array(), |
|
771 | + 'success' => isset(self::$_espresso_notices['success']) ? self::$_espresso_notices['success'] : array(), |
|
772 | + 'attention' => isset(self::$_espresso_notices['attention']) ? self::$_espresso_notices['attention'] : array(), |
|
773 | + 'errors' => isset(self::$_espresso_notices['errors']) ? self::$_espresso_notices['errors'] : array(), |
|
774 | 774 | ); |
775 | 775 | } |
776 | 776 | |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @param boolean $remove_empty whether or not to unset empty messages |
787 | 787 | * @return array |
788 | 788 | */ |
789 | - public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
|
790 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
789 | + public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) { |
|
790 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
791 | 791 | |
792 | 792 | $success_messages = ''; |
793 | 793 | $attention_messages = ''; |
@@ -797,44 +797,44 @@ discard block |
||
797 | 797 | // EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
798 | 798 | |
799 | 799 | // either save notices to the db |
800 | - if ( $save_to_transient ) { |
|
801 | - update_option( 'ee_notices', self::$_espresso_notices ); |
|
800 | + if ($save_to_transient) { |
|
801 | + update_option('ee_notices', self::$_espresso_notices); |
|
802 | 802 | return; |
803 | 803 | } |
804 | 804 | // grab any notices that have been previously saved |
805 | - if ( $notices = get_option( 'ee_notices', FALSE )) { |
|
806 | - foreach ( $notices as $type => $notice ) { |
|
807 | - if ( is_array( $notice ) && ! empty( $notice )) { |
|
805 | + if ($notices = get_option('ee_notices', FALSE)) { |
|
806 | + foreach ($notices as $type => $notice) { |
|
807 | + if (is_array($notice) && ! empty($notice)) { |
|
808 | 808 | // make sure that existing notice type is an array |
809 | - self::$_espresso_notices[ $type ] = is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array(); |
|
809 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array(); |
|
810 | 810 | // merge stored notices with any newly created ones |
811 | - self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice ); |
|
811 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
812 | 812 | $print_scripts = TRUE; |
813 | 813 | } |
814 | 814 | } |
815 | 815 | // now clear any stored notices |
816 | - update_option( 'ee_notices', FALSE ); |
|
816 | + update_option('ee_notices', FALSE); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | // check for success messages |
820 | - if ( self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] )) { |
|
820 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
821 | 821 | // combine messages |
822 | - $success_messages .= implode( self::$_espresso_notices['success'], '<br />' ); |
|
822 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br />'); |
|
823 | 823 | $print_scripts = TRUE; |
824 | 824 | } |
825 | 825 | |
826 | 826 | // check for attention messages |
827 | - if ( self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ) { |
|
827 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
828 | 828 | // combine messages |
829 | - $attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' ); |
|
829 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />'); |
|
830 | 830 | $print_scripts = TRUE; |
831 | 831 | } |
832 | 832 | |
833 | 833 | // check for error messages |
834 | - if ( self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ) { |
|
835 | - $error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' ); |
|
834 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
835 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso'); |
|
836 | 836 | // combine messages |
837 | - $error_messages .= implode( self::$_espresso_notices['errors'], '<br />' ); |
|
837 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br />'); |
|
838 | 838 | $print_scripts = TRUE; |
839 | 839 | } |
840 | 840 | |
@@ -848,21 +848,21 @@ discard block |
||
848 | 848 | $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
849 | 849 | $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
850 | 850 | //showMessage( $success_messages ); |
851 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>'; |
|
851 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>'; |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | if ($attention_messages !== '') { |
855 | 855 | $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
856 | 856 | $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
857 | 857 | //showMessage( $error_messages, TRUE ); |
858 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>'; |
|
858 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>'; |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | if ($error_messages !== '') { |
862 | 862 | $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
863 | 863 | $css_class = is_admin() ? 'error' : 'error fade-away'; |
864 | 864 | //showMessage( $error_messages, TRUE ); |
865 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>'; |
|
865 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>'; |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | $notices .= '</div>'; |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | 'errors' => $error_messages |
876 | 876 | ); |
877 | 877 | |
878 | - if ( $remove_empty ) { |
|
878 | + if ($remove_empty) { |
|
879 | 879 | // remove empty notices |
880 | 880 | foreach ($notices as $type => $notice) { |
881 | 881 | if (empty($notice)) { |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | } |
886 | 886 | } |
887 | 887 | |
888 | - if ( $print_scripts ) { |
|
888 | + if ($print_scripts) { |
|
889 | 889 | self::_print_scripts(); |
890 | 890 | } |
891 | 891 | |
@@ -905,17 +905,17 @@ discard block |
||
905 | 905 | * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
906 | 906 | * @return void |
907 | 907 | */ |
908 | - public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
|
909 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
910 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
908 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) { |
|
909 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
910 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
911 | 911 | //maybe initialize persistent_admin_notices |
912 | - if ( empty( $persistent_admin_notices )) { |
|
913 | - add_option( 'ee_pers_admin_notices', array(), '', 'no' ); |
|
912 | + if (empty($persistent_admin_notices)) { |
|
913 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
914 | 914 | } |
915 | - $pan_name = sanitize_key( $pan_name ); |
|
916 | - if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) { |
|
917 | - $persistent_admin_notices[ $pan_name ] = $pan_message; |
|
918 | - update_option( 'ee_pers_admin_notices', $persistent_admin_notices ); |
|
915 | + $pan_name = sanitize_key($pan_name); |
|
916 | + if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
917 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
918 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | } |
@@ -931,34 +931,34 @@ discard block |
||
931 | 931 | * @param bool $return_immediately |
932 | 932 | * @return void |
933 | 933 | */ |
934 | - public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) { |
|
935 | - $pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name; |
|
936 | - if ( ! empty( $pan_name )) { |
|
937 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
934 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) { |
|
935 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
936 | + if ( ! empty($pan_name)) { |
|
937 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
938 | 938 | // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
939 | - if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) { |
|
939 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
940 | 940 | // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
941 | - if ( $purge ) { |
|
942 | - unset( $persistent_admin_notices[ $pan_name ] ); |
|
941 | + if ($purge) { |
|
942 | + unset($persistent_admin_notices[$pan_name]); |
|
943 | 943 | } else { |
944 | - $persistent_admin_notices[ $pan_name ] = NULL; |
|
944 | + $persistent_admin_notices[$pan_name] = NULL; |
|
945 | 945 | } |
946 | - if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) { |
|
947 | - EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
946 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) { |
|
947 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
948 | 948 | } |
949 | 949 | } |
950 | 950 | } |
951 | - if ( $return_immediately ) { |
|
951 | + if ($return_immediately) { |
|
952 | 952 | return; |
953 | - } else if ( EE_Registry::instance()->REQ->ajax ) { |
|
953 | + } else if (EE_Registry::instance()->REQ->ajax) { |
|
954 | 954 | // grab any notices and concatenate into string |
955 | - echo wp_json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE )))); |
|
955 | + echo wp_json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE)))); |
|
956 | 956 | exit(); |
957 | 957 | } else { |
958 | 958 | // save errors to a transient to be displayed on next request (after redirect) |
959 | - EE_Error::get_notices( FALSE, TRUE ); |
|
960 | - $return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : ''; |
|
961 | - wp_safe_redirect( urldecode( $return_url )); |
|
959 | + EE_Error::get_notices(FALSE, TRUE); |
|
960 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
961 | + wp_safe_redirect(urldecode($return_url)); |
|
962 | 962 | } |
963 | 963 | } |
964 | 964 | |
@@ -973,20 +973,20 @@ discard block |
||
973 | 973 | * @param string $return_url URL to go back to after nag notice is dismissed |
974 | 974 | * @return string |
975 | 975 | */ |
976 | - public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
|
977 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
976 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') { |
|
977 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
978 | 978 | $args = array( |
979 | 979 | 'nag_notice' => $pan_name, |
980 | - 'return_url' => urlencode( $return_url ), |
|
980 | + 'return_url' => urlencode($return_url), |
|
981 | 981 | 'ajax_url' => WP_AJAX_URL, |
982 | - 'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' ) |
|
982 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso') |
|
983 | 983 | ); |
984 | - wp_localize_script( 'espresso_core', 'ee_dismiss', $args ); |
|
984 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
985 | 985 | return ' |
986 | - <div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
987 | - <p>' . $pan_message . '</p> |
|
988 | - <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '"> |
|
989 | - <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .' |
|
986 | + <div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
987 | + <p>' . $pan_message.'</p> |
|
988 | + <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'"> |
|
989 | + <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').' |
|
990 | 990 | </a> |
991 | 991 | <div style="clear:both;"></div> |
992 | 992 | </div>'; |
@@ -1003,24 +1003,24 @@ discard block |
||
1003 | 1003 | * @param string $return_url |
1004 | 1004 | * @return array |
1005 | 1005 | */ |
1006 | - public static function get_persistent_admin_notices( $return_url = '' ) { |
|
1006 | + public static function get_persistent_admin_notices($return_url = '') { |
|
1007 | 1007 | $notices = ''; |
1008 | 1008 | // check for persistent admin notices |
1009 | 1009 | //filter the list though so plugins can notify the admin in a different way if they want |
1010 | 1010 | $persistent_admin_notices = apply_filters( |
1011 | 1011 | 'FHEE__EE_Error__get_persistent_admin_notices', |
1012 | - get_option( 'ee_pers_admin_notices', FALSE ), |
|
1012 | + get_option('ee_pers_admin_notices', FALSE), |
|
1013 | 1013 | 'ee_pers_admin_notices', |
1014 | 1014 | $return_url |
1015 | 1015 | ); |
1016 | - if ( $persistent_admin_notices ) { |
|
1016 | + if ($persistent_admin_notices) { |
|
1017 | 1017 | // load scripts |
1018 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1019 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1020 | - wp_enqueue_script( 'ee_error_js' ); |
|
1018 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1019 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1020 | + wp_enqueue_script('ee_error_js'); |
|
1021 | 1021 | // and display notices |
1022 | - foreach( $persistent_admin_notices as $pan_name => $pan_message ) { |
|
1023 | - $notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url ); |
|
1022 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
1023 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | return $notices; |
@@ -1035,26 +1035,26 @@ discard block |
||
1035 | 1035 | * @param bool $force_print |
1036 | 1036 | * @return void |
1037 | 1037 | */ |
1038 | - private static function _print_scripts( $force_print = FALSE ) { |
|
1039 | - if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
|
1040 | - if ( wp_script_is( 'ee_error_js', 'enqueued' )) { |
|
1038 | + private static function _print_scripts($force_print = FALSE) { |
|
1039 | + if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) { |
|
1040 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
1041 | 1041 | return; |
1042 | - } else if ( wp_script_is( 'ee_error_js', 'registered' )) { |
|
1043 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
1044 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
1045 | - wp_enqueue_script( 'ee_error_js' ); |
|
1046 | - wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG )); |
|
1042 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
1043 | + add_filter('FHEE_load_css', '__return_true'); |
|
1044 | + add_filter('FHEE_load_js', '__return_true'); |
|
1045 | + wp_enqueue_script('ee_error_js'); |
|
1046 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG)); |
|
1047 | 1047 | } |
1048 | 1048 | } else { |
1049 | 1049 | return ' |
1050 | 1050 | <script> |
1051 | 1051 | /* <![CDATA[ */ |
1052 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
1052 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
1053 | 1053 | /* ]]> */ |
1054 | 1054 | </script> |
1055 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
1056 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
1057 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
1055 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
1056 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
1057 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
1058 | 1058 | '; |
1059 | 1059 | |
1060 | 1060 | } |
@@ -1088,11 +1088,11 @@ discard block |
||
1088 | 1088 | * @param string $line |
1089 | 1089 | * @return string |
1090 | 1090 | */ |
1091 | - public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
|
1092 | - $file = explode( '.', basename( $file )); |
|
1093 | - $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
|
1094 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
1095 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
1091 | + public static function generate_error_code($file = '', $func = '', $line = '') { |
|
1092 | + $file = explode('.', basename($file)); |
|
1093 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1094 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
1095 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
1096 | 1096 | return $error_code; |
1097 | 1097 | } |
1098 | 1098 | |
@@ -1108,36 +1108,36 @@ discard block |
||
1108 | 1108 | * @ param object $ex |
1109 | 1109 | * @ return void |
1110 | 1110 | */ |
1111 | - public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
|
1111 | + public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) { |
|
1112 | 1112 | |
1113 | - if ( ! $ex ) { |
|
1113 | + if ( ! $ex) { |
|
1114 | 1114 | return; |
1115 | 1115 | } |
1116 | 1116 | |
1117 | - if ( ! $time ) { |
|
1117 | + if ( ! $time) { |
|
1118 | 1118 | $time = time(); |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - $exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1122 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
1123 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1124 | - $exception_log .= 'Code: '. $ex['code'] . PHP_EOL; |
|
1125 | - $exception_log .= 'File: '. $ex['file'] . PHP_EOL; |
|
1126 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1127 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1128 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1129 | - $exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1121 | + $exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1122 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
1123 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
1124 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
1125 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
1126 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
1127 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
1128 | + $exception_log .= $ex['string'].PHP_EOL; |
|
1129 | + $exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1130 | 1130 | |
1131 | 1131 | try { |
1132 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ); |
|
1133 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' ); |
|
1134 | - if ( ! $clear ) { |
|
1132 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file); |
|
1133 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs'); |
|
1134 | + if ( ! $clear) { |
|
1135 | 1135 | //get existing log file and append new log info |
1136 | - $exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log; |
|
1136 | + $exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log; |
|
1137 | 1137 | } |
1138 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log ); |
|
1139 | - } catch( EE_Error $e ){ |
|
1140 | - EE_Error::add_error( sprintf( __( 'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() )); |
|
1138 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log); |
|
1139 | + } catch (EE_Error $e) { |
|
1140 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage())); |
|
1141 | 1141 | return; |
1142 | 1142 | } |
1143 | 1143 | |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | $applies_when = '', |
1174 | 1174 | $error_type = null |
1175 | 1175 | ) { |
1176 | - if ( defined('WP_DEBUG') && WP_DEBUG ) { |
|
1177 | - EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $applies_when, $error_type ); |
|
1176 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1177 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type); |
|
1178 | 1178 | } |
1179 | 1179 | } |
1180 | 1180 | |
@@ -1208,13 +1208,13 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | function espresso_error_enqueue_scripts() { |
1210 | 1210 | // js for error handling |
1211 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1212 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1211 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1212 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1213 | 1213 | } |
1214 | -if ( is_admin() ) { |
|
1215 | - add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1214 | +if (is_admin()) { |
|
1215 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1216 | 1216 | } else { |
1217 | - add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1217 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 |
@@ -32,8 +32,8 @@ |
||
32 | 32 | "price": "<?php echo $ticket['price']; ?>", |
33 | 33 | "priceCurrency": "<?php echo $currency; ?>" |
34 | 34 | }<?php if (is_array($event_tickets) && end($event_tickets) !== $ticket) { echo ','; } |
35 | - } |
|
36 | - ?> |
|
35 | + } |
|
36 | + ?> |
|
37 | 37 | ]<?php if ($venue_name) { ?>, |
38 | 38 | "location": { |
39 | 39 | "@type": "Place", |
@@ -129,54 +129,54 @@ discard block |
||
129 | 129 | define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
130 | 130 | define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
131 | 131 | // main root folder paths |
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
140 | 140 | // core system paths |
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
141 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
142 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
143 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
144 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
145 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
146 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
147 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
153 | 153 | // gateways |
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
154 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
156 | 156 | // asset URL paths |
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
163 | 163 | // define upload paths |
164 | 164 | $uploads = wp_upload_dir(); |
165 | 165 | // define the uploads directory and URL |
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
168 | 168 | // define the templates directory and URL |
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
171 | 171 | // define the gateway directory and URL |
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
174 | 174 | // languages folder/path |
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
177 | 177 | //check for dompdf fonts in uploads |
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
180 | 180 | } |
181 | 181 | //ajax constants |
182 | 182 | define( |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | //you're better to use this than its straight value (currently -1) in case you ever |
192 | 192 | //want to change its default value! or find when -1 means infinity |
193 | 193 | define('EE_INF_IN_DB', -1); |
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
194 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | 195 | define('EE_DEBUG', false); |
196 | 196 | // for older WP versions |
197 | 197 | if ( ! defined('MONTH_IN_SECONDS')) { |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | function espresso_load_error_handling() |
215 | 215 | { |
216 | 216 | // load debugging tools |
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
219 | 219 | EEH_Debug_Tools::instance(); |
220 | 220 | } |
221 | 221 | // load error handling |
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
222 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
224 | 224 | } else { |
225 | 225 | wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
226 | 226 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | if (is_readable($full_path_to_file)) { |
245 | 245 | require_once($full_path_to_file); |
246 | 246 | } else { |
247 | - throw new EE_Error ( |
|
247 | + throw new EE_Error( |
|
248 | 248 | sprintf( |
249 | 249 | esc_html__( |
250 | 250 | 'The %s class file could not be located or is not readable due to file permissions.', |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
259 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
262 | 262 | new EE_Bootstrap(); |
263 | 263 | } |
264 | 264 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | function espresso_deactivate_plugin($plugin_basename = '') |
275 | 275 | { |
276 | 276 | if ( ! function_exists('deactivate_plugins')) { |
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
277 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
278 | 278 | } |
279 | 279 | unset($_GET['activate'], $_REQUEST['activate']); |
280 | 280 | deactivate_plugins($plugin_basename); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.31.rc.009'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.31.rc.009'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |
@@ -532,11 +532,11 @@ discard block |
||
532 | 532 | { |
533 | 533 | wp_register_style( |
534 | 534 | 'events-admin-css', |
535 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
535 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
536 | 536 | array(), |
537 | 537 | EVENT_ESPRESSO_VERSION |
538 | 538 | ); |
539 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
539 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
540 | 540 | wp_enqueue_style('events-admin-css'); |
541 | 541 | wp_enqueue_style('ee-cat-admin'); |
542 | 542 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | //scripts |
545 | 545 | wp_register_script( |
546 | 546 | 'event_editor_js', |
547 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
547 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
548 | 548 | array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
549 | 549 | EVENT_ESPRESSO_VERSION, |
550 | 550 | true |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | wp_enqueue_style('espresso-ui-theme'); |
577 | 577 | wp_register_style( |
578 | 578 | 'event-editor-css', |
579 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
579 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
580 | 580 | array('ee-admin-css'), |
581 | 581 | EVENT_ESPRESSO_VERSION |
582 | 582 | ); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | //scripts |
585 | 585 | wp_register_script( |
586 | 586 | 'event-datetime-metabox', |
587 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
587 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
588 | 588 | array('event_editor_js', 'ee-datepicker'), |
589 | 589 | EVENT_ESPRESSO_VERSION |
590 | 590 | ); |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.', |
751 | 751 | 'event_espresso' |
752 | 752 | ), |
753 | - '<a href="' . admin_url('options-general.php') . '">', |
|
753 | + '<a href="'.admin_url('options-general.php').'">', |
|
754 | 754 | '</a>' |
755 | 755 | ), |
756 | 756 | __FILE__, |
@@ -820,31 +820,31 @@ discard block |
||
820 | 820 | $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
821 | 821 | $statuses = array( |
822 | 822 | 'sold_out_status' => array( |
823 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
823 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
824 | 824 | 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
825 | 825 | ), |
826 | 826 | 'active_status' => array( |
827 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
827 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
828 | 828 | 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
829 | 829 | ), |
830 | 830 | 'upcoming_status' => array( |
831 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
831 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
832 | 832 | 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
833 | 833 | ), |
834 | 834 | 'postponed_status' => array( |
835 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
835 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
836 | 836 | 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
837 | 837 | ), |
838 | 838 | 'cancelled_status' => array( |
839 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
839 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
840 | 840 | 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
841 | 841 | ), |
842 | 842 | 'expired_status' => array( |
843 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
843 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
844 | 844 | 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
845 | 845 | ), |
846 | 846 | 'inactive_status' => array( |
847 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
847 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
848 | 848 | 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
849 | 849 | ), |
850 | 850 | ); |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | { |
909 | 909 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
910 | 910 | $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
911 | - ? (array)$this->_template_args['after_list_table'] |
|
911 | + ? (array) $this->_template_args['after_list_table'] |
|
912 | 912 | : array(); |
913 | 913 | $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
914 | 914 | . EEH_Template::get_button_or_link( |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | 'button' |
918 | 918 | ); |
919 | 919 | $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
920 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
920 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
921 | 921 | 'create_new', |
922 | 922 | 'add', |
923 | 923 | array(), |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | */ |
1048 | 1048 | protected function _default_venue_update(\EE_Event $evtobj, $data) |
1049 | 1049 | { |
1050 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1050 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
1051 | 1051 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
1052 | 1052 | $rows_affected = null; |
1053 | 1053 | $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | if (empty($tkt['TKT_start_date'])) { |
1172 | 1172 | //let's use now in the set timezone. |
1173 | 1173 | $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
1174 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1174 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1175 | 1175 | } |
1176 | 1176 | if (empty($tkt['TKT_end_date'])) { |
1177 | 1177 | //use the start date of the first datetime |
@@ -1460,7 +1460,7 @@ discard block |
||
1460 | 1460 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
1461 | 1461 | // load template |
1462 | 1462 | EEH_Template::display_template( |
1463 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1463 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
1464 | 1464 | $publish_box_extra_args |
1465 | 1465 | ); |
1466 | 1466 | } |
@@ -1587,7 +1587,7 @@ discard block |
||
1587 | 1587 | ); |
1588 | 1588 | $template = apply_filters( |
1589 | 1589 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
1590 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1590 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
1591 | 1591 | ); |
1592 | 1592 | EEH_Template::display_template($template, $template_args); |
1593 | 1593 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
1607 | 1607 | { |
1608 | 1608 | $template_args = array( |
1609 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1609 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1610 | 1610 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
1611 | 1611 | : '', |
1612 | 1612 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
@@ -1660,7 +1660,7 @@ discard block |
||
1660 | 1660 | $template_args = array_merge($template_args, $price_args); |
1661 | 1661 | $template = apply_filters( |
1662 | 1662 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
1663 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1663 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
1664 | 1664 | $ticket |
1665 | 1665 | ); |
1666 | 1666 | return EEH_Template::display_template($template, $template_args, true); |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | $default_reg_status_values |
1713 | 1713 | ); |
1714 | 1714 | EEH_Template::display_template( |
1715 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1715 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
1716 | 1716 | $template_args |
1717 | 1717 | ); |
1718 | 1718 | } |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | { |
1736 | 1736 | $EEME = $this->_event_model(); |
1737 | 1737 | $offset = ($current_page - 1) * $per_page; |
1738 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1738 | + $limit = $count ? null : $offset.','.$per_page; |
|
1739 | 1739 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1740 | 1740 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1741 | 1741 | if (isset($this->_req_data['month_range'])) { |
@@ -1769,7 +1769,7 @@ discard block |
||
1769 | 1769 | $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
1770 | 1770 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1771 | 1771 | $DateTime = new DateTime( |
1772 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1772 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
1773 | 1773 | new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
1774 | 1774 | ); |
1775 | 1775 | $start = $DateTime->format(implode(' ', $start_formats)); |
@@ -1815,7 +1815,7 @@ discard block |
||
1815 | 1815 | } |
1816 | 1816 | //search query handling |
1817 | 1817 | if (isset($this->_req_data['s'])) { |
1818 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1818 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1819 | 1819 | $where['OR'] = array( |
1820 | 1820 | 'EVT_name' => array('LIKE', $search_string), |
1821 | 1821 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1949,7 +1949,7 @@ discard block |
||
1949 | 1949 | if ( ! empty($event_status)) { |
1950 | 1950 | $success = true; |
1951 | 1951 | //determine the event id and set to array. |
1952 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1952 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1953 | 1953 | // loop thru events |
1954 | 1954 | foreach ($EVT_IDs as $EVT_ID) { |
1955 | 1955 | if ($EVT_ID = absint($EVT_ID)) { |
@@ -2097,7 +2097,7 @@ discard block |
||
2097 | 2097 | // get list of events with no prices |
2098 | 2098 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
2099 | 2099 | //determine the event id and set to array. |
2100 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2100 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2101 | 2101 | // loop thru events |
2102 | 2102 | foreach ($EVT_IDs as $EVT_ID) { |
2103 | 2103 | $EVT_ID = absint($EVT_ID); |
@@ -2280,7 +2280,7 @@ discard block |
||
2280 | 2280 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2281 | 2281 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
2282 | 2282 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
2283 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2283 | + EVENTS_TEMPLATE_PATH.'event_settings.template.php', |
|
2284 | 2284 | $this->_template_args, |
2285 | 2285 | true |
2286 | 2286 | ); |
@@ -2325,10 +2325,10 @@ discard block |
||
2325 | 2325 | . 'caffeinated_template_features.jpg" alt="' |
2326 | 2326 | . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
2327 | 2327 | . '" />'; |
2328 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2328 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__( |
|
2329 | 2329 | 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
2330 | 2330 | 'event_espresso' |
2331 | - ) . '</strong>'; |
|
2331 | + ).'</strong>'; |
|
2332 | 2332 | $this->display_admin_caf_preview_page('template_settings_tab'); |
2333 | 2333 | } |
2334 | 2334 | |
@@ -2377,7 +2377,7 @@ discard block |
||
2377 | 2377 | { |
2378 | 2378 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
2379 | 2379 | $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
2380 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2380 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
2381 | 2381 | 'add_category', |
2382 | 2382 | 'add_category', |
2383 | 2383 | array(), |
@@ -2453,7 +2453,7 @@ discard block |
||
2453 | 2453 | 'disable' => '', |
2454 | 2454 | 'disabled_message' => false, |
2455 | 2455 | ); |
2456 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2456 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2457 | 2457 | return EEH_Template::display_template($template, $template_args, true); |
2458 | 2458 | } |
2459 | 2459 | |
@@ -2461,8 +2461,8 @@ discard block |
||
2461 | 2461 | |
2462 | 2462 | protected function _delete_categories() |
2463 | 2463 | { |
2464 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2465 | - : (array)$this->_req_data['category_id']; |
|
2464 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2465 | + : (array) $this->_req_data['category_id']; |
|
2466 | 2466 | foreach ($cat_ids as $cat_id) { |
2467 | 2467 | $this->_delete_category($cat_id); |
2468 | 2468 | } |
@@ -2563,7 +2563,7 @@ discard block |
||
2563 | 2563 | $limit = ($current_page - 1) * $per_page; |
2564 | 2564 | $where = array('taxonomy' => 'espresso_event_categories'); |
2565 | 2565 | if (isset($this->_req_data['s'])) { |
2566 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2566 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2567 | 2567 | $where['OR'] = array( |
2568 | 2568 | 'Term.name' => array('LIKE', $sstr), |
2569 | 2569 | 'description' => array('LIKE', $sstr), |
@@ -2572,7 +2572,7 @@ discard block |
||
2572 | 2572 | $query_params = array( |
2573 | 2573 | $where, |
2574 | 2574 | 'order_by' => array($orderby => $order), |
2575 | - 'limit' => $limit . ',' . $per_page, |
|
2575 | + 'limit' => $limit.','.$per_page, |
|
2576 | 2576 | 'force_join' => array('Term'), |
2577 | 2577 | ); |
2578 | 2578 | $categories = $count |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -17,2576 +17,2576 @@ discard block |
||
17 | 17 | class Events_Admin_Page extends EE_Admin_Page_CPT |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * This will hold the event object for event_details screen. |
|
22 | - * |
|
23 | - * @access protected |
|
24 | - * @var EE_Event $_event |
|
25 | - */ |
|
26 | - protected $_event; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * This will hold the category object for category_details screen. |
|
31 | - * |
|
32 | - * @var stdClass $_category |
|
33 | - */ |
|
34 | - protected $_category; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * This will hold the event model instance |
|
39 | - * |
|
40 | - * @var EEM_Event $_event_model |
|
41 | - */ |
|
42 | - protected $_event_model; |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @var EE_Event |
|
48 | - */ |
|
49 | - protected $_cpt_model_obj = false; |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - protected function _init_page_props() |
|
54 | - { |
|
55 | - $this->page_slug = EVENTS_PG_SLUG; |
|
56 | - $this->page_label = EVENTS_LABEL; |
|
57 | - $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
58 | - $this->_admin_base_path = EVENTS_ADMIN; |
|
59 | - $this->_cpt_model_names = array( |
|
60 | - 'create_new' => 'EEM_Event', |
|
61 | - 'edit' => 'EEM_Event', |
|
62 | - ); |
|
63 | - $this->_cpt_edit_routes = array( |
|
64 | - 'espresso_events' => 'edit', |
|
65 | - ); |
|
66 | - add_action( |
|
67 | - 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
68 | - array($this, 'verify_event_edit') |
|
69 | - ); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - |
|
74 | - protected function _ajax_hooks() |
|
75 | - { |
|
76 | - //todo: all hooks for events ajax goes in here. |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - protected function _define_page_props() |
|
82 | - { |
|
83 | - $this->_admin_page_title = EVENTS_LABEL; |
|
84 | - $this->_labels = array( |
|
85 | - 'buttons' => array( |
|
86 | - 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
87 | - 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
88 | - 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
89 | - 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
90 | - 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
91 | - 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
92 | - ), |
|
93 | - 'editor_title' => array( |
|
94 | - 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
95 | - ), |
|
96 | - 'publishbox' => array( |
|
97 | - 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
98 | - 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
99 | - 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
100 | - 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
101 | - 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
102 | - ), |
|
103 | - ); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - protected function _set_page_routes() |
|
109 | - { |
|
110 | - //load formatter helper |
|
111 | - //load field generator helper |
|
112 | - //is there a evt_id in the request? |
|
113 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
114 | - ? $this->_req_data['EVT_ID'] : 0; |
|
115 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
116 | - $this->_page_routes = array( |
|
117 | - 'default' => array( |
|
118 | - 'func' => '_events_overview_list_table', |
|
119 | - 'capability' => 'ee_read_events', |
|
120 | - ), |
|
121 | - 'create_new' => array( |
|
122 | - 'func' => '_create_new_cpt_item', |
|
123 | - 'capability' => 'ee_edit_events', |
|
124 | - ), |
|
125 | - 'edit' => array( |
|
126 | - 'func' => '_edit_cpt_item', |
|
127 | - 'capability' => 'ee_edit_event', |
|
128 | - 'obj_id' => $evt_id, |
|
129 | - ), |
|
130 | - 'copy_event' => array( |
|
131 | - 'func' => '_copy_events', |
|
132 | - 'capability' => 'ee_edit_event', |
|
133 | - 'obj_id' => $evt_id, |
|
134 | - 'noheader' => true, |
|
135 | - ), |
|
136 | - 'trash_event' => array( |
|
137 | - 'func' => '_trash_or_restore_event', |
|
138 | - 'args' => array('event_status' => 'trash'), |
|
139 | - 'capability' => 'ee_delete_event', |
|
140 | - 'obj_id' => $evt_id, |
|
141 | - 'noheader' => true, |
|
142 | - ), |
|
143 | - 'trash_events' => array( |
|
144 | - 'func' => '_trash_or_restore_events', |
|
145 | - 'args' => array('event_status' => 'trash'), |
|
146 | - 'capability' => 'ee_delete_events', |
|
147 | - 'noheader' => true, |
|
148 | - ), |
|
149 | - 'restore_event' => array( |
|
150 | - 'func' => '_trash_or_restore_event', |
|
151 | - 'args' => array('event_status' => 'draft'), |
|
152 | - 'capability' => 'ee_delete_event', |
|
153 | - 'obj_id' => $evt_id, |
|
154 | - 'noheader' => true, |
|
155 | - ), |
|
156 | - 'restore_events' => array( |
|
157 | - 'func' => '_trash_or_restore_events', |
|
158 | - 'args' => array('event_status' => 'draft'), |
|
159 | - 'capability' => 'ee_delete_events', |
|
160 | - 'noheader' => true, |
|
161 | - ), |
|
162 | - 'delete_event' => array( |
|
163 | - 'func' => '_delete_event', |
|
164 | - 'capability' => 'ee_delete_event', |
|
165 | - 'obj_id' => $evt_id, |
|
166 | - 'noheader' => true, |
|
167 | - ), |
|
168 | - 'delete_events' => array( |
|
169 | - 'func' => '_delete_events', |
|
170 | - 'capability' => 'ee_delete_events', |
|
171 | - 'noheader' => true, |
|
172 | - ), |
|
173 | - 'view_report' => array( |
|
174 | - 'func' => '_view_report', |
|
175 | - 'capablity' => 'ee_edit_events', |
|
176 | - ), |
|
177 | - 'default_event_settings' => array( |
|
178 | - 'func' => '_default_event_settings', |
|
179 | - 'capability' => 'manage_options', |
|
180 | - ), |
|
181 | - 'update_default_event_settings' => array( |
|
182 | - 'func' => '_update_default_event_settings', |
|
183 | - 'capability' => 'manage_options', |
|
184 | - 'noheader' => true, |
|
185 | - ), |
|
186 | - 'template_settings' => array( |
|
187 | - 'func' => '_template_settings', |
|
188 | - 'capability' => 'manage_options', |
|
189 | - ), |
|
190 | - //event category tab related |
|
191 | - 'add_category' => array( |
|
192 | - 'func' => '_category_details', |
|
193 | - 'capability' => 'ee_edit_event_category', |
|
194 | - 'args' => array('add'), |
|
195 | - ), |
|
196 | - 'edit_category' => array( |
|
197 | - 'func' => '_category_details', |
|
198 | - 'capability' => 'ee_edit_event_category', |
|
199 | - 'args' => array('edit'), |
|
200 | - ), |
|
201 | - 'delete_categories' => array( |
|
202 | - 'func' => '_delete_categories', |
|
203 | - 'capability' => 'ee_delete_event_category', |
|
204 | - 'noheader' => true, |
|
205 | - ), |
|
206 | - 'delete_category' => array( |
|
207 | - 'func' => '_delete_categories', |
|
208 | - 'capability' => 'ee_delete_event_category', |
|
209 | - 'noheader' => true, |
|
210 | - ), |
|
211 | - 'insert_category' => array( |
|
212 | - 'func' => '_insert_or_update_category', |
|
213 | - 'args' => array('new_category' => true), |
|
214 | - 'capability' => 'ee_edit_event_category', |
|
215 | - 'noheader' => true, |
|
216 | - ), |
|
217 | - 'update_category' => array( |
|
218 | - 'func' => '_insert_or_update_category', |
|
219 | - 'args' => array('new_category' => false), |
|
220 | - 'capability' => 'ee_edit_event_category', |
|
221 | - 'noheader' => true, |
|
222 | - ), |
|
223 | - 'category_list' => array( |
|
224 | - 'func' => '_category_list_table', |
|
225 | - 'capability' => 'ee_manage_event_categories', |
|
226 | - ), |
|
227 | - ); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - |
|
232 | - protected function _set_page_config() |
|
233 | - { |
|
234 | - $this->_page_config = array( |
|
235 | - 'default' => array( |
|
236 | - 'nav' => array( |
|
237 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
238 | - 'order' => 10, |
|
239 | - ), |
|
240 | - 'list_table' => 'Events_Admin_List_Table', |
|
241 | - 'help_tabs' => array( |
|
242 | - 'events_overview_help_tab' => array( |
|
243 | - 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
244 | - 'filename' => 'events_overview', |
|
245 | - ), |
|
246 | - 'events_overview_table_column_headings_help_tab' => array( |
|
247 | - 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
248 | - 'filename' => 'events_overview_table_column_headings', |
|
249 | - ), |
|
250 | - 'events_overview_filters_help_tab' => array( |
|
251 | - 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
252 | - 'filename' => 'events_overview_filters', |
|
253 | - ), |
|
254 | - 'events_overview_view_help_tab' => array( |
|
255 | - 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
256 | - 'filename' => 'events_overview_views', |
|
257 | - ), |
|
258 | - 'events_overview_other_help_tab' => array( |
|
259 | - 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
260 | - 'filename' => 'events_overview_other', |
|
261 | - ), |
|
262 | - ), |
|
263 | - 'help_tour' => array( |
|
264 | - 'Event_Overview_Help_Tour', |
|
265 | - //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
266 | - ), |
|
267 | - 'qtips' => array( |
|
268 | - 'EE_Event_List_Table_Tips', |
|
269 | - ), |
|
270 | - 'require_nonce' => false, |
|
271 | - ), |
|
272 | - 'create_new' => array( |
|
273 | - 'nav' => array( |
|
274 | - 'label' => esc_html__('Add Event', 'event_espresso'), |
|
275 | - 'order' => 5, |
|
276 | - 'persistent' => false, |
|
277 | - ), |
|
278 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
279 | - 'help_tabs' => array( |
|
280 | - 'event_editor_help_tab' => array( |
|
281 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
282 | - 'filename' => 'event_editor', |
|
283 | - ), |
|
284 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
285 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
286 | - 'filename' => 'event_editor_title_richtexteditor', |
|
287 | - ), |
|
288 | - 'event_editor_venue_details_help_tab' => array( |
|
289 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
290 | - 'filename' => 'event_editor_venue_details', |
|
291 | - ), |
|
292 | - 'event_editor_event_datetimes_help_tab' => array( |
|
293 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
294 | - 'filename' => 'event_editor_event_datetimes', |
|
295 | - ), |
|
296 | - 'event_editor_event_tickets_help_tab' => array( |
|
297 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
298 | - 'filename' => 'event_editor_event_tickets', |
|
299 | - ), |
|
300 | - 'event_editor_event_registration_options_help_tab' => array( |
|
301 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
302 | - 'filename' => 'event_editor_event_registration_options', |
|
303 | - ), |
|
304 | - 'event_editor_tags_categories_help_tab' => array( |
|
305 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
306 | - 'filename' => 'event_editor_tags_categories', |
|
307 | - ), |
|
308 | - 'event_editor_questions_registrants_help_tab' => array( |
|
309 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
310 | - 'filename' => 'event_editor_questions_registrants', |
|
311 | - ), |
|
312 | - 'event_editor_save_new_event_help_tab' => array( |
|
313 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
314 | - 'filename' => 'event_editor_save_new_event', |
|
315 | - ), |
|
316 | - 'event_editor_other_help_tab' => array( |
|
317 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
318 | - 'filename' => 'event_editor_other', |
|
319 | - ), |
|
320 | - ), |
|
321 | - 'help_tour' => array( |
|
322 | - 'Event_Editor_Help_Tour', |
|
323 | - ), |
|
324 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
325 | - 'require_nonce' => false, |
|
326 | - ), |
|
327 | - 'edit' => array( |
|
328 | - 'nav' => array( |
|
329 | - 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
330 | - 'order' => 5, |
|
331 | - 'persistent' => false, |
|
332 | - 'url' => isset($this->_req_data['post']) |
|
333 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
334 | - array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
335 | - $this->_current_page_view_url |
|
336 | - ) |
|
337 | - : $this->_admin_base_url, |
|
338 | - ), |
|
339 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
340 | - 'help_tabs' => array( |
|
341 | - 'event_editor_help_tab' => array( |
|
342 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
343 | - 'filename' => 'event_editor', |
|
344 | - ), |
|
345 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
346 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
347 | - 'filename' => 'event_editor_title_richtexteditor', |
|
348 | - ), |
|
349 | - 'event_editor_venue_details_help_tab' => array( |
|
350 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
351 | - 'filename' => 'event_editor_venue_details', |
|
352 | - ), |
|
353 | - 'event_editor_event_datetimes_help_tab' => array( |
|
354 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
355 | - 'filename' => 'event_editor_event_datetimes', |
|
356 | - ), |
|
357 | - 'event_editor_event_tickets_help_tab' => array( |
|
358 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
359 | - 'filename' => 'event_editor_event_tickets', |
|
360 | - ), |
|
361 | - 'event_editor_event_registration_options_help_tab' => array( |
|
362 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
363 | - 'filename' => 'event_editor_event_registration_options', |
|
364 | - ), |
|
365 | - 'event_editor_tags_categories_help_tab' => array( |
|
366 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
367 | - 'filename' => 'event_editor_tags_categories', |
|
368 | - ), |
|
369 | - 'event_editor_questions_registrants_help_tab' => array( |
|
370 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
371 | - 'filename' => 'event_editor_questions_registrants', |
|
372 | - ), |
|
373 | - 'event_editor_save_new_event_help_tab' => array( |
|
374 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
375 | - 'filename' => 'event_editor_save_new_event', |
|
376 | - ), |
|
377 | - 'event_editor_other_help_tab' => array( |
|
378 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
379 | - 'filename' => 'event_editor_other', |
|
380 | - ), |
|
381 | - ), |
|
382 | - /*'help_tour' => array( |
|
20 | + /** |
|
21 | + * This will hold the event object for event_details screen. |
|
22 | + * |
|
23 | + * @access protected |
|
24 | + * @var EE_Event $_event |
|
25 | + */ |
|
26 | + protected $_event; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * This will hold the category object for category_details screen. |
|
31 | + * |
|
32 | + * @var stdClass $_category |
|
33 | + */ |
|
34 | + protected $_category; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * This will hold the event model instance |
|
39 | + * |
|
40 | + * @var EEM_Event $_event_model |
|
41 | + */ |
|
42 | + protected $_event_model; |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @var EE_Event |
|
48 | + */ |
|
49 | + protected $_cpt_model_obj = false; |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + protected function _init_page_props() |
|
54 | + { |
|
55 | + $this->page_slug = EVENTS_PG_SLUG; |
|
56 | + $this->page_label = EVENTS_LABEL; |
|
57 | + $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
58 | + $this->_admin_base_path = EVENTS_ADMIN; |
|
59 | + $this->_cpt_model_names = array( |
|
60 | + 'create_new' => 'EEM_Event', |
|
61 | + 'edit' => 'EEM_Event', |
|
62 | + ); |
|
63 | + $this->_cpt_edit_routes = array( |
|
64 | + 'espresso_events' => 'edit', |
|
65 | + ); |
|
66 | + add_action( |
|
67 | + 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
68 | + array($this, 'verify_event_edit') |
|
69 | + ); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + |
|
74 | + protected function _ajax_hooks() |
|
75 | + { |
|
76 | + //todo: all hooks for events ajax goes in here. |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + protected function _define_page_props() |
|
82 | + { |
|
83 | + $this->_admin_page_title = EVENTS_LABEL; |
|
84 | + $this->_labels = array( |
|
85 | + 'buttons' => array( |
|
86 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
87 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
88 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
89 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
90 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
91 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
92 | + ), |
|
93 | + 'editor_title' => array( |
|
94 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
95 | + ), |
|
96 | + 'publishbox' => array( |
|
97 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
98 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
99 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
100 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
101 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
102 | + ), |
|
103 | + ); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + protected function _set_page_routes() |
|
109 | + { |
|
110 | + //load formatter helper |
|
111 | + //load field generator helper |
|
112 | + //is there a evt_id in the request? |
|
113 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
114 | + ? $this->_req_data['EVT_ID'] : 0; |
|
115 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
116 | + $this->_page_routes = array( |
|
117 | + 'default' => array( |
|
118 | + 'func' => '_events_overview_list_table', |
|
119 | + 'capability' => 'ee_read_events', |
|
120 | + ), |
|
121 | + 'create_new' => array( |
|
122 | + 'func' => '_create_new_cpt_item', |
|
123 | + 'capability' => 'ee_edit_events', |
|
124 | + ), |
|
125 | + 'edit' => array( |
|
126 | + 'func' => '_edit_cpt_item', |
|
127 | + 'capability' => 'ee_edit_event', |
|
128 | + 'obj_id' => $evt_id, |
|
129 | + ), |
|
130 | + 'copy_event' => array( |
|
131 | + 'func' => '_copy_events', |
|
132 | + 'capability' => 'ee_edit_event', |
|
133 | + 'obj_id' => $evt_id, |
|
134 | + 'noheader' => true, |
|
135 | + ), |
|
136 | + 'trash_event' => array( |
|
137 | + 'func' => '_trash_or_restore_event', |
|
138 | + 'args' => array('event_status' => 'trash'), |
|
139 | + 'capability' => 'ee_delete_event', |
|
140 | + 'obj_id' => $evt_id, |
|
141 | + 'noheader' => true, |
|
142 | + ), |
|
143 | + 'trash_events' => array( |
|
144 | + 'func' => '_trash_or_restore_events', |
|
145 | + 'args' => array('event_status' => 'trash'), |
|
146 | + 'capability' => 'ee_delete_events', |
|
147 | + 'noheader' => true, |
|
148 | + ), |
|
149 | + 'restore_event' => array( |
|
150 | + 'func' => '_trash_or_restore_event', |
|
151 | + 'args' => array('event_status' => 'draft'), |
|
152 | + 'capability' => 'ee_delete_event', |
|
153 | + 'obj_id' => $evt_id, |
|
154 | + 'noheader' => true, |
|
155 | + ), |
|
156 | + 'restore_events' => array( |
|
157 | + 'func' => '_trash_or_restore_events', |
|
158 | + 'args' => array('event_status' => 'draft'), |
|
159 | + 'capability' => 'ee_delete_events', |
|
160 | + 'noheader' => true, |
|
161 | + ), |
|
162 | + 'delete_event' => array( |
|
163 | + 'func' => '_delete_event', |
|
164 | + 'capability' => 'ee_delete_event', |
|
165 | + 'obj_id' => $evt_id, |
|
166 | + 'noheader' => true, |
|
167 | + ), |
|
168 | + 'delete_events' => array( |
|
169 | + 'func' => '_delete_events', |
|
170 | + 'capability' => 'ee_delete_events', |
|
171 | + 'noheader' => true, |
|
172 | + ), |
|
173 | + 'view_report' => array( |
|
174 | + 'func' => '_view_report', |
|
175 | + 'capablity' => 'ee_edit_events', |
|
176 | + ), |
|
177 | + 'default_event_settings' => array( |
|
178 | + 'func' => '_default_event_settings', |
|
179 | + 'capability' => 'manage_options', |
|
180 | + ), |
|
181 | + 'update_default_event_settings' => array( |
|
182 | + 'func' => '_update_default_event_settings', |
|
183 | + 'capability' => 'manage_options', |
|
184 | + 'noheader' => true, |
|
185 | + ), |
|
186 | + 'template_settings' => array( |
|
187 | + 'func' => '_template_settings', |
|
188 | + 'capability' => 'manage_options', |
|
189 | + ), |
|
190 | + //event category tab related |
|
191 | + 'add_category' => array( |
|
192 | + 'func' => '_category_details', |
|
193 | + 'capability' => 'ee_edit_event_category', |
|
194 | + 'args' => array('add'), |
|
195 | + ), |
|
196 | + 'edit_category' => array( |
|
197 | + 'func' => '_category_details', |
|
198 | + 'capability' => 'ee_edit_event_category', |
|
199 | + 'args' => array('edit'), |
|
200 | + ), |
|
201 | + 'delete_categories' => array( |
|
202 | + 'func' => '_delete_categories', |
|
203 | + 'capability' => 'ee_delete_event_category', |
|
204 | + 'noheader' => true, |
|
205 | + ), |
|
206 | + 'delete_category' => array( |
|
207 | + 'func' => '_delete_categories', |
|
208 | + 'capability' => 'ee_delete_event_category', |
|
209 | + 'noheader' => true, |
|
210 | + ), |
|
211 | + 'insert_category' => array( |
|
212 | + 'func' => '_insert_or_update_category', |
|
213 | + 'args' => array('new_category' => true), |
|
214 | + 'capability' => 'ee_edit_event_category', |
|
215 | + 'noheader' => true, |
|
216 | + ), |
|
217 | + 'update_category' => array( |
|
218 | + 'func' => '_insert_or_update_category', |
|
219 | + 'args' => array('new_category' => false), |
|
220 | + 'capability' => 'ee_edit_event_category', |
|
221 | + 'noheader' => true, |
|
222 | + ), |
|
223 | + 'category_list' => array( |
|
224 | + 'func' => '_category_list_table', |
|
225 | + 'capability' => 'ee_manage_event_categories', |
|
226 | + ), |
|
227 | + ); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + |
|
232 | + protected function _set_page_config() |
|
233 | + { |
|
234 | + $this->_page_config = array( |
|
235 | + 'default' => array( |
|
236 | + 'nav' => array( |
|
237 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
238 | + 'order' => 10, |
|
239 | + ), |
|
240 | + 'list_table' => 'Events_Admin_List_Table', |
|
241 | + 'help_tabs' => array( |
|
242 | + 'events_overview_help_tab' => array( |
|
243 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
244 | + 'filename' => 'events_overview', |
|
245 | + ), |
|
246 | + 'events_overview_table_column_headings_help_tab' => array( |
|
247 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
248 | + 'filename' => 'events_overview_table_column_headings', |
|
249 | + ), |
|
250 | + 'events_overview_filters_help_tab' => array( |
|
251 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
252 | + 'filename' => 'events_overview_filters', |
|
253 | + ), |
|
254 | + 'events_overview_view_help_tab' => array( |
|
255 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
256 | + 'filename' => 'events_overview_views', |
|
257 | + ), |
|
258 | + 'events_overview_other_help_tab' => array( |
|
259 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
260 | + 'filename' => 'events_overview_other', |
|
261 | + ), |
|
262 | + ), |
|
263 | + 'help_tour' => array( |
|
264 | + 'Event_Overview_Help_Tour', |
|
265 | + //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
266 | + ), |
|
267 | + 'qtips' => array( |
|
268 | + 'EE_Event_List_Table_Tips', |
|
269 | + ), |
|
270 | + 'require_nonce' => false, |
|
271 | + ), |
|
272 | + 'create_new' => array( |
|
273 | + 'nav' => array( |
|
274 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
275 | + 'order' => 5, |
|
276 | + 'persistent' => false, |
|
277 | + ), |
|
278 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
279 | + 'help_tabs' => array( |
|
280 | + 'event_editor_help_tab' => array( |
|
281 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
282 | + 'filename' => 'event_editor', |
|
283 | + ), |
|
284 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
285 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
286 | + 'filename' => 'event_editor_title_richtexteditor', |
|
287 | + ), |
|
288 | + 'event_editor_venue_details_help_tab' => array( |
|
289 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
290 | + 'filename' => 'event_editor_venue_details', |
|
291 | + ), |
|
292 | + 'event_editor_event_datetimes_help_tab' => array( |
|
293 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
294 | + 'filename' => 'event_editor_event_datetimes', |
|
295 | + ), |
|
296 | + 'event_editor_event_tickets_help_tab' => array( |
|
297 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
298 | + 'filename' => 'event_editor_event_tickets', |
|
299 | + ), |
|
300 | + 'event_editor_event_registration_options_help_tab' => array( |
|
301 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
302 | + 'filename' => 'event_editor_event_registration_options', |
|
303 | + ), |
|
304 | + 'event_editor_tags_categories_help_tab' => array( |
|
305 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
306 | + 'filename' => 'event_editor_tags_categories', |
|
307 | + ), |
|
308 | + 'event_editor_questions_registrants_help_tab' => array( |
|
309 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
310 | + 'filename' => 'event_editor_questions_registrants', |
|
311 | + ), |
|
312 | + 'event_editor_save_new_event_help_tab' => array( |
|
313 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
314 | + 'filename' => 'event_editor_save_new_event', |
|
315 | + ), |
|
316 | + 'event_editor_other_help_tab' => array( |
|
317 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
318 | + 'filename' => 'event_editor_other', |
|
319 | + ), |
|
320 | + ), |
|
321 | + 'help_tour' => array( |
|
322 | + 'Event_Editor_Help_Tour', |
|
323 | + ), |
|
324 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
325 | + 'require_nonce' => false, |
|
326 | + ), |
|
327 | + 'edit' => array( |
|
328 | + 'nav' => array( |
|
329 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
330 | + 'order' => 5, |
|
331 | + 'persistent' => false, |
|
332 | + 'url' => isset($this->_req_data['post']) |
|
333 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
334 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
335 | + $this->_current_page_view_url |
|
336 | + ) |
|
337 | + : $this->_admin_base_url, |
|
338 | + ), |
|
339 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
340 | + 'help_tabs' => array( |
|
341 | + 'event_editor_help_tab' => array( |
|
342 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
343 | + 'filename' => 'event_editor', |
|
344 | + ), |
|
345 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
346 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
347 | + 'filename' => 'event_editor_title_richtexteditor', |
|
348 | + ), |
|
349 | + 'event_editor_venue_details_help_tab' => array( |
|
350 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
351 | + 'filename' => 'event_editor_venue_details', |
|
352 | + ), |
|
353 | + 'event_editor_event_datetimes_help_tab' => array( |
|
354 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
355 | + 'filename' => 'event_editor_event_datetimes', |
|
356 | + ), |
|
357 | + 'event_editor_event_tickets_help_tab' => array( |
|
358 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
359 | + 'filename' => 'event_editor_event_tickets', |
|
360 | + ), |
|
361 | + 'event_editor_event_registration_options_help_tab' => array( |
|
362 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
363 | + 'filename' => 'event_editor_event_registration_options', |
|
364 | + ), |
|
365 | + 'event_editor_tags_categories_help_tab' => array( |
|
366 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
367 | + 'filename' => 'event_editor_tags_categories', |
|
368 | + ), |
|
369 | + 'event_editor_questions_registrants_help_tab' => array( |
|
370 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
371 | + 'filename' => 'event_editor_questions_registrants', |
|
372 | + ), |
|
373 | + 'event_editor_save_new_event_help_tab' => array( |
|
374 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
375 | + 'filename' => 'event_editor_save_new_event', |
|
376 | + ), |
|
377 | + 'event_editor_other_help_tab' => array( |
|
378 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
379 | + 'filename' => 'event_editor_other', |
|
380 | + ), |
|
381 | + ), |
|
382 | + /*'help_tour' => array( |
|
383 | 383 | 'Event_Edit_Help_Tour' |
384 | 384 | ),*/ |
385 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
386 | - 'require_nonce' => false, |
|
387 | - ), |
|
388 | - 'default_event_settings' => array( |
|
389 | - 'nav' => array( |
|
390 | - 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
391 | - 'order' => 40, |
|
392 | - ), |
|
393 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
394 | - 'labels' => array( |
|
395 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
396 | - ), |
|
397 | - 'help_tabs' => array( |
|
398 | - 'default_settings_help_tab' => array( |
|
399 | - 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
400 | - 'filename' => 'events_default_settings', |
|
401 | - ), |
|
402 | - 'default_settings_status_help_tab' => array( |
|
403 | - 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
404 | - 'filename' => 'events_default_settings_status', |
|
405 | - ), |
|
406 | - ), |
|
407 | - 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
408 | - 'require_nonce' => false, |
|
409 | - ), |
|
410 | - //template settings |
|
411 | - 'template_settings' => array( |
|
412 | - 'nav' => array( |
|
413 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
414 | - 'order' => 30, |
|
415 | - ), |
|
416 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
417 | - 'help_tabs' => array( |
|
418 | - 'general_settings_templates_help_tab' => array( |
|
419 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
420 | - 'filename' => 'general_settings_templates', |
|
421 | - ), |
|
422 | - ), |
|
423 | - 'help_tour' => array('Templates_Help_Tour'), |
|
424 | - 'require_nonce' => false, |
|
425 | - ), |
|
426 | - //event category stuff |
|
427 | - 'add_category' => array( |
|
428 | - 'nav' => array( |
|
429 | - 'label' => esc_html__('Add Category', 'event_espresso'), |
|
430 | - 'order' => 15, |
|
431 | - 'persistent' => false, |
|
432 | - ), |
|
433 | - 'help_tabs' => array( |
|
434 | - 'add_category_help_tab' => array( |
|
435 | - 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
436 | - 'filename' => 'events_add_category', |
|
437 | - ), |
|
438 | - ), |
|
439 | - 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
440 | - 'metaboxes' => array('_publish_post_box'), |
|
441 | - 'require_nonce' => false, |
|
442 | - ), |
|
443 | - 'edit_category' => array( |
|
444 | - 'nav' => array( |
|
445 | - 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
446 | - 'order' => 15, |
|
447 | - 'persistent' => false, |
|
448 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
449 | - ? add_query_arg( |
|
450 | - array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
451 | - $this->_current_page_view_url |
|
452 | - ) |
|
453 | - : $this->_admin_base_url, |
|
454 | - ), |
|
455 | - 'help_tabs' => array( |
|
456 | - 'edit_category_help_tab' => array( |
|
457 | - 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
458 | - 'filename' => 'events_edit_category', |
|
459 | - ), |
|
460 | - ), |
|
461 | - /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
462 | - 'metaboxes' => array('_publish_post_box'), |
|
463 | - 'require_nonce' => false, |
|
464 | - ), |
|
465 | - 'category_list' => array( |
|
466 | - 'nav' => array( |
|
467 | - 'label' => esc_html__('Categories', 'event_espresso'), |
|
468 | - 'order' => 20, |
|
469 | - ), |
|
470 | - 'list_table' => 'Event_Categories_Admin_List_Table', |
|
471 | - 'help_tabs' => array( |
|
472 | - 'events_categories_help_tab' => array( |
|
473 | - 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
474 | - 'filename' => 'events_categories', |
|
475 | - ), |
|
476 | - 'events_categories_table_column_headings_help_tab' => array( |
|
477 | - 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
478 | - 'filename' => 'events_categories_table_column_headings', |
|
479 | - ), |
|
480 | - 'events_categories_view_help_tab' => array( |
|
481 | - 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
482 | - 'filename' => 'events_categories_views', |
|
483 | - ), |
|
484 | - 'events_categories_other_help_tab' => array( |
|
485 | - 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
486 | - 'filename' => 'events_categories_other', |
|
487 | - ), |
|
488 | - ), |
|
489 | - 'help_tour' => array( |
|
490 | - 'Event_Categories_Help_Tour', |
|
491 | - ), |
|
492 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
493 | - 'require_nonce' => false, |
|
494 | - ), |
|
495 | - ); |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - |
|
500 | - protected function _add_screen_options() |
|
501 | - { |
|
502 | - //todo |
|
503 | - } |
|
504 | - |
|
505 | - |
|
506 | - |
|
507 | - protected function _add_screen_options_default() |
|
508 | - { |
|
509 | - $this->_per_page_screen_option(); |
|
510 | - } |
|
511 | - |
|
512 | - |
|
513 | - |
|
514 | - protected function _add_screen_options_category_list() |
|
515 | - { |
|
516 | - $page_title = $this->_admin_page_title; |
|
517 | - $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
518 | - $this->_per_page_screen_option(); |
|
519 | - $this->_admin_page_title = $page_title; |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - |
|
524 | - protected function _add_feature_pointers() |
|
525 | - { |
|
526 | - //todo |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - |
|
531 | - public function load_scripts_styles() |
|
532 | - { |
|
533 | - wp_register_style( |
|
534 | - 'events-admin-css', |
|
535 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
536 | - array(), |
|
537 | - EVENT_ESPRESSO_VERSION |
|
538 | - ); |
|
539 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
540 | - wp_enqueue_style('events-admin-css'); |
|
541 | - wp_enqueue_style('ee-cat-admin'); |
|
542 | - //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
543 | - //registers for all views |
|
544 | - //scripts |
|
545 | - wp_register_script( |
|
546 | - 'event_editor_js', |
|
547 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
548 | - array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
549 | - EVENT_ESPRESSO_VERSION, |
|
550 | - true |
|
551 | - ); |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * enqueuing scripts and styles specific to this view |
|
558 | - * |
|
559 | - * @return void |
|
560 | - */ |
|
561 | - public function load_scripts_styles_create_new() |
|
562 | - { |
|
563 | - $this->load_scripts_styles_edit(); |
|
564 | - } |
|
565 | - |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * enqueuing scripts and styles specific to this view |
|
570 | - * |
|
571 | - * @return void |
|
572 | - */ |
|
573 | - public function load_scripts_styles_edit() |
|
574 | - { |
|
575 | - //styles |
|
576 | - wp_enqueue_style('espresso-ui-theme'); |
|
577 | - wp_register_style( |
|
578 | - 'event-editor-css', |
|
579 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
580 | - array('ee-admin-css'), |
|
581 | - EVENT_ESPRESSO_VERSION |
|
582 | - ); |
|
583 | - wp_enqueue_style('event-editor-css'); |
|
584 | - //scripts |
|
585 | - wp_register_script( |
|
586 | - 'event-datetime-metabox', |
|
587 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
588 | - array('event_editor_js', 'ee-datepicker'), |
|
589 | - EVENT_ESPRESSO_VERSION |
|
590 | - ); |
|
591 | - wp_enqueue_script('event-datetime-metabox'); |
|
592 | - } |
|
593 | - |
|
594 | - |
|
595 | - |
|
596 | - public function load_scripts_styles_add_category() |
|
597 | - { |
|
598 | - $this->load_scripts_styles_edit_category(); |
|
599 | - } |
|
600 | - |
|
601 | - |
|
602 | - |
|
603 | - public function load_scripts_styles_edit_category() |
|
604 | - { |
|
605 | - } |
|
606 | - |
|
607 | - |
|
608 | - |
|
609 | - protected function _set_list_table_views_category_list() |
|
610 | - { |
|
611 | - $this->_views = array( |
|
612 | - 'all' => array( |
|
613 | - 'slug' => 'all', |
|
614 | - 'label' => esc_html__('All', 'event_espresso'), |
|
615 | - 'count' => 0, |
|
616 | - 'bulk_action' => array( |
|
617 | - 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
618 | - ), |
|
619 | - ), |
|
620 | - ); |
|
621 | - } |
|
622 | - |
|
623 | - |
|
624 | - |
|
625 | - public function admin_init() |
|
626 | - { |
|
627 | - EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
628 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
629 | - 'event_espresso' |
|
630 | - ); |
|
631 | - } |
|
632 | - |
|
633 | - |
|
634 | - |
|
635 | - //nothing needed for events with these methods. |
|
636 | - public function admin_notices() |
|
637 | - { |
|
638 | - } |
|
639 | - |
|
640 | - |
|
641 | - |
|
642 | - public function admin_footer_scripts() |
|
643 | - { |
|
644 | - } |
|
645 | - |
|
646 | - |
|
647 | - |
|
648 | - /** |
|
649 | - * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
650 | - * warning (via EE_Error::add_error()); |
|
651 | - * |
|
652 | - * @param EE_Event $event Event object |
|
653 | - * @access public |
|
654 | - * @return void |
|
655 | - */ |
|
656 | - public function verify_event_edit($event = null) |
|
657 | - { |
|
658 | - // no event? |
|
659 | - if (empty($event)) { |
|
660 | - // set event |
|
661 | - $event = $this->_cpt_model_obj; |
|
662 | - } |
|
663 | - // STILL no event? |
|
664 | - if (empty ($event)) { |
|
665 | - return; |
|
666 | - } |
|
667 | - $orig_status = $event->status(); |
|
668 | - // first check if event is active. |
|
669 | - if ( |
|
670 | - $orig_status === EEM_Event::cancelled |
|
671 | - || $orig_status === EEM_Event::postponed |
|
672 | - || $event->is_expired() |
|
673 | - || $event->is_inactive() |
|
674 | - ) { |
|
675 | - return; |
|
676 | - } |
|
677 | - //made it here so it IS active... next check that any of the tickets are sold. |
|
678 | - if ($event->is_sold_out(true)) { |
|
679 | - if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
680 | - EE_Error::add_attention( |
|
681 | - sprintf( |
|
682 | - esc_html__( |
|
683 | - 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
684 | - 'event_espresso' |
|
685 | - ), |
|
686 | - EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
687 | - ) |
|
688 | - ); |
|
689 | - } |
|
690 | - return; |
|
691 | - } else if ($orig_status === EEM_Event::sold_out) { |
|
692 | - EE_Error::add_attention( |
|
693 | - sprintf( |
|
694 | - esc_html__( |
|
695 | - 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
696 | - 'event_espresso' |
|
697 | - ), |
|
698 | - EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
699 | - ) |
|
700 | - ); |
|
701 | - } |
|
702 | - //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
703 | - if ( ! $event->tickets_on_sale()) { |
|
704 | - return; |
|
705 | - } |
|
706 | - //made it here so show warning |
|
707 | - $this->_edit_event_warning(); |
|
708 | - } |
|
709 | - |
|
710 | - |
|
711 | - |
|
712 | - /** |
|
713 | - * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
714 | - * When needed, hook this into a EE_Error::add_error() notice. |
|
715 | - * |
|
716 | - * @access protected |
|
717 | - * @return void |
|
718 | - */ |
|
719 | - protected function _edit_event_warning() |
|
720 | - { |
|
721 | - // we don't want to add warnings during these requests |
|
722 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
723 | - return; |
|
724 | - } |
|
725 | - EE_Error::add_attention( |
|
726 | - esc_html__( |
|
727 | - 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
728 | - 'event_espresso' |
|
729 | - ) |
|
730 | - ); |
|
731 | - } |
|
732 | - |
|
733 | - |
|
734 | - |
|
735 | - /** |
|
736 | - * When a user is creating a new event, notify them if they haven't set their timezone. |
|
737 | - * Otherwise, do the normal logic |
|
738 | - * |
|
739 | - * @return string |
|
740 | - * @throws \EE_Error |
|
741 | - */ |
|
742 | - protected function _create_new_cpt_item() |
|
743 | - { |
|
744 | - $gmt_offset = get_option('gmt_offset'); |
|
745 | - //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
746 | - if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
747 | - EE_Error::add_attention( |
|
748 | - sprintf( |
|
749 | - __( |
|
750 | - 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.', |
|
751 | - 'event_espresso' |
|
752 | - ), |
|
753 | - '<a href="' . admin_url('options-general.php') . '">', |
|
754 | - '</a>' |
|
755 | - ), |
|
756 | - __FILE__, |
|
757 | - __FUNCTION__, |
|
758 | - __LINE__ |
|
759 | - ); |
|
760 | - } |
|
761 | - return parent::_create_new_cpt_item(); |
|
762 | - } |
|
763 | - |
|
764 | - |
|
765 | - |
|
766 | - protected function _set_list_table_views_default() |
|
767 | - { |
|
768 | - $this->_views = array( |
|
769 | - 'all' => array( |
|
770 | - 'slug' => 'all', |
|
771 | - 'label' => esc_html__('View All Events', 'event_espresso'), |
|
772 | - 'count' => 0, |
|
773 | - 'bulk_action' => array( |
|
774 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
775 | - ), |
|
776 | - ), |
|
777 | - 'draft' => array( |
|
778 | - 'slug' => 'draft', |
|
779 | - 'label' => esc_html__('Draft', 'event_espresso'), |
|
780 | - 'count' => 0, |
|
781 | - 'bulk_action' => array( |
|
782 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
783 | - ), |
|
784 | - ), |
|
785 | - ); |
|
786 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
787 | - $this->_views['trash'] = array( |
|
788 | - 'slug' => 'trash', |
|
789 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
790 | - 'count' => 0, |
|
791 | - 'bulk_action' => array( |
|
792 | - 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
793 | - 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
794 | - ), |
|
795 | - ); |
|
796 | - } |
|
797 | - } |
|
798 | - |
|
799 | - |
|
800 | - |
|
801 | - /** |
|
802 | - * @return array |
|
803 | - */ |
|
804 | - protected function _event_legend_items() |
|
805 | - { |
|
806 | - $items = array( |
|
807 | - 'view_details' => array( |
|
808 | - 'class' => 'dashicons dashicons-search', |
|
809 | - 'desc' => esc_html__('View Event', 'event_espresso'), |
|
810 | - ), |
|
811 | - 'edit_event' => array( |
|
812 | - 'class' => 'ee-icon ee-icon-calendar-edit', |
|
813 | - 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
814 | - ), |
|
815 | - 'view_attendees' => array( |
|
816 | - 'class' => 'dashicons dashicons-groups', |
|
817 | - 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
818 | - ), |
|
819 | - ); |
|
820 | - $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
821 | - $statuses = array( |
|
822 | - 'sold_out_status' => array( |
|
823 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
824 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
825 | - ), |
|
826 | - 'active_status' => array( |
|
827 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
828 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
829 | - ), |
|
830 | - 'upcoming_status' => array( |
|
831 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
832 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
833 | - ), |
|
834 | - 'postponed_status' => array( |
|
835 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
836 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
837 | - ), |
|
838 | - 'cancelled_status' => array( |
|
839 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
840 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
841 | - ), |
|
842 | - 'expired_status' => array( |
|
843 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
844 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
845 | - ), |
|
846 | - 'inactive_status' => array( |
|
847 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
848 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
849 | - ), |
|
850 | - ); |
|
851 | - $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
852 | - return array_merge($items, $statuses); |
|
853 | - } |
|
854 | - |
|
855 | - |
|
856 | - |
|
857 | - /** |
|
858 | - * _event_model |
|
859 | - * |
|
860 | - * @return EEM_Event |
|
861 | - */ |
|
862 | - private function _event_model() |
|
863 | - { |
|
864 | - if ( ! $this->_event_model instanceof EEM_Event) { |
|
865 | - $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
866 | - } |
|
867 | - return $this->_event_model; |
|
868 | - } |
|
869 | - |
|
870 | - |
|
871 | - |
|
872 | - /** |
|
873 | - * Adds extra buttons to the WP CPT permalink field row. |
|
874 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
875 | - * |
|
876 | - * @param string $return the current html |
|
877 | - * @param int $id the post id for the page |
|
878 | - * @param string $new_title What the title is |
|
879 | - * @param string $new_slug what the slug is |
|
880 | - * @return string The new html string for the permalink area |
|
881 | - */ |
|
882 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
883 | - { |
|
884 | - //make sure this is only when editing |
|
885 | - if ( ! empty($id)) { |
|
886 | - $post = get_post($id); |
|
887 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
888 | - . esc_html__('Shortcode', 'event_espresso') |
|
889 | - . '</a> '; |
|
890 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
891 | - . $post->ID |
|
892 | - . ']">'; |
|
893 | - } |
|
894 | - return $return; |
|
895 | - } |
|
896 | - |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * _events_overview_list_table |
|
901 | - * This contains the logic for showing the events_overview list |
|
902 | - * |
|
903 | - * @access protected |
|
904 | - * @return void |
|
905 | - * @throws \EE_Error |
|
906 | - */ |
|
907 | - protected function _events_overview_list_table() |
|
908 | - { |
|
909 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
910 | - $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
911 | - ? (array)$this->_template_args['after_list_table'] |
|
912 | - : array(); |
|
913 | - $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
914 | - . EEH_Template::get_button_or_link( |
|
915 | - get_post_type_archive_link('espresso_events'), |
|
916 | - esc_html__("View Event Archive Page", "event_espresso"), |
|
917 | - 'button' |
|
918 | - ); |
|
919 | - $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
920 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
921 | - 'create_new', |
|
922 | - 'add', |
|
923 | - array(), |
|
924 | - 'add-new-h2' |
|
925 | - ); |
|
926 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
927 | - } |
|
928 | - |
|
929 | - |
|
930 | - |
|
931 | - /** |
|
932 | - * this allows for extra misc actions in the default WP publish box |
|
933 | - * |
|
934 | - * @return void |
|
935 | - */ |
|
936 | - public function extra_misc_actions_publish_box() |
|
937 | - { |
|
938 | - $this->_generate_publish_box_extra_content(); |
|
939 | - } |
|
940 | - |
|
941 | - |
|
942 | - |
|
943 | - /** |
|
944 | - * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
945 | - * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
946 | - * data. |
|
947 | - * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
948 | - * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
949 | - * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
950 | - * you handle this accordingly. |
|
951 | - * |
|
952 | - * @access protected |
|
953 | - * @abstract |
|
954 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
955 | - * @param object $post The post object of the cpt that was saved. |
|
956 | - * @return void |
|
957 | - */ |
|
958 | - protected function _insert_update_cpt_item($post_id, $post) |
|
959 | - { |
|
960 | - if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
961 | - //get out we're not processing an event save. |
|
962 | - return; |
|
963 | - } |
|
964 | - $event_values = array( |
|
965 | - 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
966 | - 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
967 | - 'EVT_additional_limit' => min( |
|
968 | - apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
969 | - ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
970 | - ), |
|
971 | - 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
972 | - ? $this->_req_data['EVT_default_registration_status'] |
|
973 | - : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
974 | - 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
975 | - 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
976 | - 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
977 | - ? $this->_req_data['timezone_string'] : null, |
|
978 | - 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
979 | - ? $this->_req_data['externalURL'] : null, |
|
980 | - 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
981 | - ? $this->_req_data['event_phone'] : null, |
|
982 | - ); |
|
983 | - //update event |
|
984 | - $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
985 | - //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_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! |
|
986 | - $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
987 | - $event = $this->_event_model()->get_one(array($get_one_where)); |
|
988 | - //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
989 | - $event_update_callbacks = apply_filters( |
|
990 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
991 | - array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
992 | - ); |
|
993 | - $att_success = true; |
|
994 | - foreach ($event_update_callbacks as $e_callback) { |
|
995 | - $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
996 | - $att_success = ! $att_success ? $att_success |
|
997 | - : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
998 | - } |
|
999 | - //any errors? |
|
1000 | - if ($success && false === $att_success) { |
|
1001 | - EE_Error::add_error( |
|
1002 | - esc_html__( |
|
1003 | - 'Event Details saved successfully but something went wrong with saving attachments.', |
|
1004 | - 'event_espresso' |
|
1005 | - ), |
|
1006 | - __FILE__, |
|
1007 | - __FUNCTION__, |
|
1008 | - __LINE__ |
|
1009 | - ); |
|
1010 | - } else if ($success === false) { |
|
1011 | - EE_Error::add_error( |
|
1012 | - esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
1013 | - __FILE__, |
|
1014 | - __FUNCTION__, |
|
1015 | - __LINE__ |
|
1016 | - ); |
|
1017 | - } |
|
1018 | - } |
|
1019 | - |
|
1020 | - |
|
1021 | - |
|
1022 | - /** |
|
1023 | - * @see parent::restore_item() |
|
1024 | - * @param int $post_id |
|
1025 | - * @param int $revision_id |
|
1026 | - */ |
|
1027 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
1028 | - { |
|
1029 | - //copy existing event meta to new post |
|
1030 | - $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1031 | - if ($post_evt instanceof EE_Event) { |
|
1032 | - //meta revision restore |
|
1033 | - $post_evt->restore_revision($revision_id); |
|
1034 | - //related objs restore |
|
1035 | - $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1036 | - } |
|
1037 | - } |
|
1038 | - |
|
1039 | - |
|
1040 | - |
|
1041 | - /** |
|
1042 | - * Attach the venue to the Event |
|
1043 | - * |
|
1044 | - * @param \EE_Event $evtobj Event Object to add the venue to |
|
1045 | - * @param array $data The request data from the form |
|
1046 | - * @return bool Success or fail. |
|
1047 | - */ |
|
1048 | - protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1049 | - { |
|
1050 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1051 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1052 | - $rows_affected = null; |
|
1053 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1054 | - // very important. If we don't have a venue name... |
|
1055 | - // then we'll get out because not necessary to create empty venue |
|
1056 | - if (empty($data['venue_title'])) { |
|
1057 | - return false; |
|
1058 | - } |
|
1059 | - $venue_array = array( |
|
1060 | - 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1061 | - 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1062 | - 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1063 | - 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1064 | - 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1065 | - : null, |
|
1066 | - 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1067 | - 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1068 | - 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1069 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1070 | - 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1071 | - 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1072 | - 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1073 | - 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1074 | - 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1075 | - 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1076 | - 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1077 | - 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1078 | - 'status' => 'publish', |
|
1079 | - ); |
|
1080 | - //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1081 | - if ( ! empty($venue_id)) { |
|
1082 | - $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1083 | - $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1084 | - //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
1085 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1086 | - return $rows_affected > 0 ? true : false; |
|
1087 | - } else { |
|
1088 | - //we insert the venue |
|
1089 | - $venue_id = $venue_model->insert($venue_array); |
|
1090 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1091 | - return ! empty($venue_id) ? true : false; |
|
1092 | - } |
|
1093 | - //when we have the ancestor come in it's already been handled by the revision save. |
|
1094 | - } |
|
1095 | - |
|
1096 | - |
|
1097 | - |
|
1098 | - /** |
|
1099 | - * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1100 | - * |
|
1101 | - * @param EE_Event $evtobj The Event object we're attaching data to |
|
1102 | - * @param array $data The request data from the form |
|
1103 | - * @return array |
|
1104 | - */ |
|
1105 | - protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1106 | - { |
|
1107 | - $success = true; |
|
1108 | - $saved_dtt = null; |
|
1109 | - $saved_tickets = array(); |
|
1110 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1111 | - foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1112 | - //trim all values to ensure any excess whitespace is removed. |
|
1113 | - $dtt = array_map('trim', $dtt); |
|
1114 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1115 | - : $dtt['DTT_EVT_start']; |
|
1116 | - $datetime_values = array( |
|
1117 | - 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1118 | - 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1119 | - 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1120 | - 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1121 | - 'DTT_order' => $row, |
|
1122 | - ); |
|
1123 | - //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
1124 | - if ( ! empty($dtt['DTT_ID'])) { |
|
1125 | - $DTM = EE_Registry::instance() |
|
1126 | - ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1127 | - ->get_one_by_ID($dtt['DTT_ID']); |
|
1128 | - $DTM->set_date_format($incoming_date_formats[0]); |
|
1129 | - $DTM->set_time_format($incoming_date_formats[1]); |
|
1130 | - foreach ($datetime_values as $field => $value) { |
|
1131 | - $DTM->set($field, $value); |
|
1132 | - } |
|
1133 | - //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
1134 | - $saved_dtts[$DTM->ID()] = $DTM; |
|
1135 | - } else { |
|
1136 | - $DTM = EE_Registry::instance()->load_class( |
|
1137 | - 'Datetime', |
|
1138 | - array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
1139 | - false, |
|
1140 | - false |
|
1141 | - ); |
|
1142 | - foreach ($datetime_values as $field => $value) { |
|
1143 | - $DTM->set($field, $value); |
|
1144 | - } |
|
1145 | - } |
|
1146 | - $DTM->save(); |
|
1147 | - $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1148 | - //load DTT helper |
|
1149 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1150 | - if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1151 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1152 | - $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1153 | - $DTT->save(); |
|
1154 | - } |
|
1155 | - //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
1156 | - $saved_dtt = $DTT; |
|
1157 | - $success = ! $success ? $success : $DTT; |
|
1158 | - //if ANY of these updates fail then we want the appropriate global error message. |
|
1159 | - // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1160 | - } |
|
1161 | - //no dtts get deleted so we don't do any of that logic here. |
|
1162 | - //update tickets next |
|
1163 | - $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1164 | - foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1165 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1166 | - $update_prices = false; |
|
1167 | - $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1168 | - ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1169 | - // trim inputs to ensure any excess whitespace is removed. |
|
1170 | - $tkt = array_map('trim', $tkt); |
|
1171 | - if (empty($tkt['TKT_start_date'])) { |
|
1172 | - //let's use now in the set timezone. |
|
1173 | - $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1174 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1175 | - } |
|
1176 | - if (empty($tkt['TKT_end_date'])) { |
|
1177 | - //use the start date of the first datetime |
|
1178 | - $dtt = $evtobj->first_datetime(); |
|
1179 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1180 | - $incoming_date_formats[0], |
|
1181 | - $incoming_date_formats[1] |
|
1182 | - ); |
|
1183 | - } |
|
1184 | - $TKT_values = array( |
|
1185 | - 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1186 | - 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1187 | - 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1188 | - 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1189 | - 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1190 | - 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1191 | - 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1192 | - 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1193 | - 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1194 | - 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1195 | - 'TKT_row' => $row, |
|
1196 | - 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1197 | - 'TKT_price' => $ticket_price, |
|
1198 | - ); |
|
1199 | - //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
1200 | - if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1201 | - $TKT_values['TKT_ID'] = 0; |
|
1202 | - $TKT_values['TKT_is_default'] = 0; |
|
1203 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1204 | - $update_prices = true; |
|
1205 | - } |
|
1206 | - //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1207 | - //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
1208 | - //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
1209 | - if ( ! empty($tkt['TKT_ID'])) { |
|
1210 | - $TKT = EE_Registry::instance() |
|
1211 | - ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1212 | - ->get_one_by_ID($tkt['TKT_ID']); |
|
1213 | - if ($TKT instanceof EE_Ticket) { |
|
1214 | - $ticket_sold = $TKT->count_related( |
|
1215 | - 'Registration', |
|
1216 | - array( |
|
1217 | - array( |
|
1218 | - 'STS_ID' => array( |
|
1219 | - 'NOT IN', |
|
1220 | - array(EEM_Registration::status_id_incomplete), |
|
1221 | - ), |
|
1222 | - ), |
|
1223 | - ) |
|
1224 | - ) > 0 ? true : false; |
|
1225 | - //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
1226 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1227 | - && ! $TKT->get( |
|
1228 | - 'TKT_deleted' |
|
1229 | - ) ? true : false; |
|
1230 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1231 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1232 | - //set new values |
|
1233 | - foreach ($TKT_values as $field => $value) { |
|
1234 | - if ($field == 'TKT_qty') { |
|
1235 | - $TKT->set_qty($value); |
|
1236 | - } else { |
|
1237 | - $TKT->set($field, $value); |
|
1238 | - } |
|
1239 | - } |
|
1240 | - //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1241 | - if ($create_new_TKT) { |
|
1242 | - //archive the old ticket first |
|
1243 | - $TKT->set('TKT_deleted', 1); |
|
1244 | - $TKT->save(); |
|
1245 | - //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1246 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1247 | - //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
1248 | - $TKT = clone $TKT; |
|
1249 | - $TKT->set('TKT_ID', 0); |
|
1250 | - $TKT->set('TKT_deleted', 0); |
|
1251 | - $TKT->set('TKT_price', $ticket_price); |
|
1252 | - $TKT->set('TKT_sold', 0); |
|
1253 | - //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1254 | - $update_prices = true; |
|
1255 | - } |
|
1256 | - //make sure price is set if it hasn't been already |
|
1257 | - $TKT->set('TKT_price', $ticket_price); |
|
1258 | - } |
|
1259 | - } else { |
|
1260 | - //no TKT_id so a new TKT |
|
1261 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1262 | - $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1263 | - if ($TKT instanceof EE_Ticket) { |
|
1264 | - //need to reset values to properly account for the date formats |
|
1265 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1266 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1267 | - $TKT->set_timezone($evtobj->get_timezone()); |
|
1268 | - //set new values |
|
1269 | - foreach ($TKT_values as $field => $value) { |
|
1270 | - if ($field == 'TKT_qty') { |
|
1271 | - $TKT->set_qty($value); |
|
1272 | - } else { |
|
1273 | - $TKT->set($field, $value); |
|
1274 | - } |
|
1275 | - } |
|
1276 | - $update_prices = true; |
|
1277 | - } |
|
1278 | - } |
|
1279 | - // cap ticket qty by datetime reg limits |
|
1280 | - $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1281 | - //update ticket. |
|
1282 | - $TKT->save(); |
|
1283 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1284 | - if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1285 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1286 | - $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1287 | - $TKT->save(); |
|
1288 | - } |
|
1289 | - //initially let's add the ticket to the dtt |
|
1290 | - $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1291 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1292 | - //add prices to ticket |
|
1293 | - $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1294 | - } |
|
1295 | - //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
1296 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1297 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1298 | - foreach ($tickets_removed as $id) { |
|
1299 | - $id = absint($id); |
|
1300 | - //get the ticket for this id |
|
1301 | - $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1302 | - //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
1303 | - $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1304 | - foreach ($dtts as $dtt) { |
|
1305 | - $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1306 | - } |
|
1307 | - //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
1308 | - $tkt_to_remove->delete_related_permanently('Price'); |
|
1309 | - //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1310 | - $tkt_to_remove->delete_permanently(); |
|
1311 | - } |
|
1312 | - return array($saved_dtt, $saved_tickets); |
|
1313 | - } |
|
1314 | - |
|
1315 | - |
|
1316 | - |
|
1317 | - /** |
|
1318 | - * This attaches a list of given prices to a ticket. |
|
1319 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1320 | - * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1321 | - * price info and prices are automatically "archived" via the ticket. |
|
1322 | - * |
|
1323 | - * @access private |
|
1324 | - * @param array $prices Array of prices from the form. |
|
1325 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1326 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1327 | - * @return void |
|
1328 | - */ |
|
1329 | - private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1330 | - { |
|
1331 | - foreach ($prices as $row => $prc) { |
|
1332 | - $PRC_values = array( |
|
1333 | - 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1334 | - 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1335 | - 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1336 | - 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1337 | - 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1338 | - 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1339 | - 'PRC_order' => $row, |
|
1340 | - ); |
|
1341 | - if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1342 | - $PRC_values['PRC_ID'] = 0; |
|
1343 | - $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1344 | - } else { |
|
1345 | - $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1346 | - //update this price with new values |
|
1347 | - foreach ($PRC_values as $field => $newprc) { |
|
1348 | - $PRC->set($field, $newprc); |
|
1349 | - } |
|
1350 | - $PRC->save(); |
|
1351 | - } |
|
1352 | - $ticket->_add_relation_to($PRC, 'Price'); |
|
1353 | - } |
|
1354 | - } |
|
1355 | - |
|
1356 | - |
|
1357 | - |
|
1358 | - /** |
|
1359 | - * Add in our autosave ajax handlers |
|
1360 | - * |
|
1361 | - * @return void |
|
1362 | - */ |
|
1363 | - protected function _ee_autosave_create_new() |
|
1364 | - { |
|
1365 | - // $this->_ee_autosave_edit(); |
|
1366 | - } |
|
1367 | - |
|
1368 | - |
|
1369 | - |
|
1370 | - protected function _ee_autosave_edit() |
|
1371 | - { |
|
1372 | - return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1373 | - } |
|
1374 | - |
|
1375 | - |
|
1376 | - |
|
1377 | - /** |
|
1378 | - * _generate_publish_box_extra_content |
|
1379 | - * |
|
1380 | - * @access private |
|
1381 | - * @return void |
|
1382 | - */ |
|
1383 | - private function _generate_publish_box_extra_content() |
|
1384 | - { |
|
1385 | - //load formatter helper |
|
1386 | - //args for getting related registrations |
|
1387 | - $approved_query_args = array( |
|
1388 | - array( |
|
1389 | - 'REG_deleted' => 0, |
|
1390 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
1391 | - ), |
|
1392 | - ); |
|
1393 | - $not_approved_query_args = array( |
|
1394 | - array( |
|
1395 | - 'REG_deleted' => 0, |
|
1396 | - 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1397 | - ), |
|
1398 | - ); |
|
1399 | - $pending_payment_query_args = array( |
|
1400 | - array( |
|
1401 | - 'REG_deleted' => 0, |
|
1402 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1403 | - ), |
|
1404 | - ); |
|
1405 | - // publish box |
|
1406 | - $publish_box_extra_args = array( |
|
1407 | - 'view_approved_reg_url' => add_query_arg( |
|
1408 | - array( |
|
1409 | - 'action' => 'default', |
|
1410 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1411 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1412 | - ), |
|
1413 | - REG_ADMIN_URL |
|
1414 | - ), |
|
1415 | - 'view_not_approved_reg_url' => add_query_arg( |
|
1416 | - array( |
|
1417 | - 'action' => 'default', |
|
1418 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1419 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1420 | - ), |
|
1421 | - REG_ADMIN_URL |
|
1422 | - ), |
|
1423 | - 'view_pending_payment_reg_url' => add_query_arg( |
|
1424 | - array( |
|
1425 | - 'action' => 'default', |
|
1426 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1427 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1428 | - ), |
|
1429 | - REG_ADMIN_URL |
|
1430 | - ), |
|
1431 | - 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1432 | - 'Registration', |
|
1433 | - $approved_query_args |
|
1434 | - ), |
|
1435 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1436 | - 'Registration', |
|
1437 | - $not_approved_query_args |
|
1438 | - ), |
|
1439 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1440 | - 'Registration', |
|
1441 | - $pending_payment_query_args |
|
1442 | - ), |
|
1443 | - 'misc_pub_section_class' => apply_filters( |
|
1444 | - 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1445 | - 'misc-pub-section' |
|
1446 | - ), |
|
1447 | - //'email_attendees_url' => add_query_arg( |
|
1448 | - // array( |
|
1449 | - // 'event_admin_reports' => 'event_newsletter', |
|
1450 | - // 'event_id' => $this->_cpt_model_obj->id |
|
1451 | - // ), |
|
1452 | - // 'admin.php?page=espresso_registrations' |
|
1453 | - //), |
|
1454 | - ); |
|
1455 | - ob_start(); |
|
1456 | - do_action( |
|
1457 | - 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1458 | - $this->_cpt_model_obj |
|
1459 | - ); |
|
1460 | - $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1461 | - // load template |
|
1462 | - EEH_Template::display_template( |
|
1463 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1464 | - $publish_box_extra_args |
|
1465 | - ); |
|
1466 | - } |
|
1467 | - |
|
1468 | - |
|
1469 | - |
|
1470 | - /** |
|
1471 | - * This just returns whatever is set as the _event object property |
|
1472 | - * //todo this will become obsolete once the models are in place |
|
1473 | - * |
|
1474 | - * @return object |
|
1475 | - */ |
|
1476 | - public function get_event_object() |
|
1477 | - { |
|
1478 | - return $this->_cpt_model_obj; |
|
1479 | - } |
|
1480 | - |
|
1481 | - |
|
1482 | - |
|
1483 | - |
|
1484 | - /** METABOXES * */ |
|
1485 | - /** |
|
1486 | - * _register_event_editor_meta_boxes |
|
1487 | - * add all metaboxes related to the event_editor |
|
1488 | - * |
|
1489 | - * @return void |
|
1490 | - */ |
|
1491 | - protected function _register_event_editor_meta_boxes() |
|
1492 | - { |
|
1493 | - $this->verify_cpt_object(); |
|
1494 | - add_meta_box( |
|
1495 | - 'espresso_event_editor_tickets', |
|
1496 | - esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1497 | - array($this, 'ticket_metabox'), |
|
1498 | - $this->page_slug, |
|
1499 | - 'normal', |
|
1500 | - 'high' |
|
1501 | - ); |
|
1502 | - add_meta_box( |
|
1503 | - 'espresso_event_editor_event_options', |
|
1504 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
1505 | - array($this, 'registration_options_meta_box'), |
|
1506 | - $this->page_slug, |
|
1507 | - 'side', |
|
1508 | - 'default' |
|
1509 | - ); |
|
1510 | - // NOTE: if you're looking for other metaboxes in here, |
|
1511 | - // where a metabox has a related management page in the admin |
|
1512 | - // you will find it setup in the related management page's "_Hooks" file. |
|
1513 | - // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1514 | - } |
|
1515 | - |
|
1516 | - |
|
1517 | - |
|
1518 | - public function ticket_metabox() |
|
1519 | - { |
|
1520 | - $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1521 | - //defaults for template args |
|
1522 | - $template_args = array( |
|
1523 | - 'existing_datetime_ids' => '', |
|
1524 | - 'event_datetime_help_link' => '', |
|
1525 | - 'ticket_options_help_link' => '', |
|
1526 | - 'time' => null, |
|
1527 | - 'ticket_rows' => '', |
|
1528 | - 'existing_ticket_ids' => '', |
|
1529 | - 'total_ticket_rows' => 1, |
|
1530 | - 'ticket_js_structure' => '', |
|
1531 | - 'trash_icon' => 'ee-lock-icon', |
|
1532 | - 'disabled' => '', |
|
1533 | - ); |
|
1534 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1535 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1536 | - /** |
|
1537 | - * 1. Start with retrieving Datetimes |
|
1538 | - * 2. Fore each datetime get related tickets |
|
1539 | - * 3. For each ticket get related prices |
|
1540 | - */ |
|
1541 | - $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1542 | - /** @type EE_Datetime $first_datetime */ |
|
1543 | - $first_datetime = reset($times); |
|
1544 | - //do we get related tickets? |
|
1545 | - if ($first_datetime instanceof EE_Datetime |
|
1546 | - && $first_datetime->ID() !== 0 |
|
1547 | - ) { |
|
1548 | - $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1549 | - $template_args['time'] = $first_datetime; |
|
1550 | - $related_tickets = $first_datetime->tickets( |
|
1551 | - array( |
|
1552 | - array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1553 | - 'default_where_conditions' => 'none', |
|
1554 | - ) |
|
1555 | - ); |
|
1556 | - if ( ! empty($related_tickets)) { |
|
1557 | - $template_args['total_ticket_rows'] = count($related_tickets); |
|
1558 | - $row = 0; |
|
1559 | - foreach ($related_tickets as $ticket) { |
|
1560 | - $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1561 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1562 | - $row++; |
|
1563 | - } |
|
1564 | - } else { |
|
1565 | - $template_args['total_ticket_rows'] = 1; |
|
1566 | - /** @type EE_Ticket $ticket */ |
|
1567 | - $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1568 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1569 | - } |
|
1570 | - } else { |
|
1571 | - $template_args['time'] = $times[0]; |
|
1572 | - /** @type EE_Ticket $ticket */ |
|
1573 | - $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1574 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1575 | - // NOTE: we're just sending the first default row |
|
1576 | - // (decaf can't manage default tickets so this should be sufficient); |
|
1577 | - } |
|
1578 | - $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1579 | - 'event_editor_event_datetimes_help_tab' |
|
1580 | - ); |
|
1581 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1582 | - $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1583 | - $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1584 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1585 | - EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1586 | - true |
|
1587 | - ); |
|
1588 | - $template = apply_filters( |
|
1589 | - 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1590 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1591 | - ); |
|
1592 | - EEH_Template::display_template($template, $template_args); |
|
1593 | - } |
|
1594 | - |
|
1595 | - |
|
1596 | - |
|
1597 | - /** |
|
1598 | - * Setup an individual ticket form for the decaf event editor page |
|
1599 | - * |
|
1600 | - * @access private |
|
1601 | - * @param EE_Ticket $ticket the ticket object |
|
1602 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1603 | - * @param int $row |
|
1604 | - * @return string generated html for the ticket row. |
|
1605 | - */ |
|
1606 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1607 | - { |
|
1608 | - $template_args = array( |
|
1609 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1610 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1611 | - : '', |
|
1612 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1613 | - 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1614 | - 'TKT_name' => $ticket->get('TKT_name'), |
|
1615 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1616 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1617 | - 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1618 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1619 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1620 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1621 | - 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1622 | - && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1623 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1624 | - 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1625 | - : ' disabled=disabled', |
|
1626 | - ); |
|
1627 | - $price = $ticket->ID() !== 0 |
|
1628 | - ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1629 | - : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1630 | - $price_args = array( |
|
1631 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1632 | - 'PRC_amount' => $price->get('PRC_amount'), |
|
1633 | - 'PRT_ID' => $price->get('PRT_ID'), |
|
1634 | - 'PRC_ID' => $price->get('PRC_ID'), |
|
1635 | - 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1636 | - ); |
|
1637 | - //make sure we have default start and end dates if skeleton |
|
1638 | - //handle rows that should NOT be empty |
|
1639 | - if (empty($template_args['TKT_start_date'])) { |
|
1640 | - //if empty then the start date will be now. |
|
1641 | - $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1642 | - } |
|
1643 | - if (empty($template_args['TKT_end_date'])) { |
|
1644 | - //get the earliest datetime (if present); |
|
1645 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1646 | - ? $this->_cpt_model_obj->get_first_related( |
|
1647 | - 'Datetime', |
|
1648 | - array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1649 | - ) |
|
1650 | - : null; |
|
1651 | - if ( ! empty($earliest_dtt)) { |
|
1652 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1653 | - } else { |
|
1654 | - $template_args['TKT_end_date'] = date( |
|
1655 | - 'Y-m-d h:i a', |
|
1656 | - mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1657 | - ); |
|
1658 | - } |
|
1659 | - } |
|
1660 | - $template_args = array_merge($template_args, $price_args); |
|
1661 | - $template = apply_filters( |
|
1662 | - 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1663 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1664 | - $ticket |
|
1665 | - ); |
|
1666 | - return EEH_Template::display_template($template, $template_args, true); |
|
1667 | - } |
|
1668 | - |
|
1669 | - |
|
1670 | - |
|
1671 | - public function registration_options_meta_box() |
|
1672 | - { |
|
1673 | - $yes_no_values = array( |
|
1674 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1675 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1676 | - ); |
|
1677 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1678 | - array( |
|
1679 | - EEM_Registration::status_id_cancelled, |
|
1680 | - EEM_Registration::status_id_declined, |
|
1681 | - EEM_Registration::status_id_incomplete, |
|
1682 | - ), |
|
1683 | - true |
|
1684 | - ); |
|
1685 | - //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1686 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
1687 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1688 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1689 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1690 | - 'default_reg_status', |
|
1691 | - $default_reg_status_values, |
|
1692 | - $this->_cpt_model_obj->default_registration_status() |
|
1693 | - ); |
|
1694 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1695 | - 'display_desc', |
|
1696 | - $yes_no_values, |
|
1697 | - $this->_cpt_model_obj->display_description() |
|
1698 | - ); |
|
1699 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1700 | - 'display_ticket_selector', |
|
1701 | - $yes_no_values, |
|
1702 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
1703 | - '', |
|
1704 | - '', |
|
1705 | - false |
|
1706 | - ); |
|
1707 | - $template_args['additional_registration_options'] = apply_filters( |
|
1708 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1709 | - '', |
|
1710 | - $template_args, |
|
1711 | - $yes_no_values, |
|
1712 | - $default_reg_status_values |
|
1713 | - ); |
|
1714 | - EEH_Template::display_template( |
|
1715 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1716 | - $template_args |
|
1717 | - ); |
|
1718 | - } |
|
1719 | - |
|
1720 | - |
|
1721 | - |
|
1722 | - /** |
|
1723 | - * _get_events() |
|
1724 | - * This method simply returns all the events (for the given _view and paging) |
|
1725 | - * |
|
1726 | - * @access public |
|
1727 | - * @param int $per_page count of items per page (20 default); |
|
1728 | - * @param int $current_page what is the current page being viewed. |
|
1729 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1730 | - * If FALSE then we return an array of event objects |
|
1731 | - * that match the given _view and paging parameters. |
|
1732 | - * @return array an array of event objects. |
|
1733 | - */ |
|
1734 | - public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1735 | - { |
|
1736 | - $EEME = $this->_event_model(); |
|
1737 | - $offset = ($current_page - 1) * $per_page; |
|
1738 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1739 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1740 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1741 | - if (isset($this->_req_data['month_range'])) { |
|
1742 | - $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1743 | - //simulate the FIRST day of the month, that fixes issues for months like February |
|
1744 | - //where PHP doesn't know what to assume for date. |
|
1745 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10437 |
|
1746 | - $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; |
|
1747 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1748 | - } |
|
1749 | - $where = array(); |
|
1750 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1751 | - //determine what post_status our condition will have for the query. |
|
1752 | - switch ($status) { |
|
1753 | - case 'month' : |
|
1754 | - case 'today' : |
|
1755 | - case null : |
|
1756 | - case 'all' : |
|
1757 | - break; |
|
1758 | - case 'draft' : |
|
1759 | - $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1760 | - break; |
|
1761 | - default : |
|
1762 | - $where['status'] = $status; |
|
1763 | - } |
|
1764 | - //categories? |
|
1765 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1766 | - ? $this->_req_data['EVT_CAT'] : null; |
|
1767 | - if ( ! empty ($category)) { |
|
1768 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1769 | - $where['Term_Taxonomy.term_id'] = $category; |
|
1770 | - } |
|
1771 | - //date where conditions |
|
1772 | - $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1773 | - if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1774 | - $DateTime = new DateTime( |
|
1775 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1776 | - new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1777 | - ); |
|
1778 | - $start = $DateTime->format(implode(' ', $start_formats)); |
|
1779 | - $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
1780 | - ->format('t'))->setTime(23, 59, 59) |
|
1781 | - ->format(implode(' ', $start_formats)); |
|
1782 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1783 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1784 | - $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1785 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1786 | - $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1787 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1788 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1789 | - $now = date('Y-m-01'); |
|
1790 | - $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1791 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1792 | - $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1793 | - ->setTime(23, 59, 59) |
|
1794 | - ->format(implode(' ', $start_formats)); |
|
1795 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1796 | - } |
|
1797 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1798 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1799 | - } else { |
|
1800 | - if ( ! isset($where['status'])) { |
|
1801 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1802 | - $where['OR'] = array( |
|
1803 | - 'status*restrict_private' => array('!=', 'private'), |
|
1804 | - 'AND' => array( |
|
1805 | - 'status*inclusive' => array('=', 'private'), |
|
1806 | - 'EVT_wp_user' => get_current_user_id(), |
|
1807 | - ), |
|
1808 | - ); |
|
1809 | - } |
|
1810 | - } |
|
1811 | - } |
|
1812 | - if (isset($this->_req_data['EVT_wp_user'])) { |
|
1813 | - if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1814 | - && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1815 | - ) { |
|
1816 | - $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1817 | - } |
|
1818 | - } |
|
1819 | - //search query handling |
|
1820 | - if (isset($this->_req_data['s'])) { |
|
1821 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1822 | - $where['OR'] = array( |
|
1823 | - 'EVT_name' => array('LIKE', $search_string), |
|
1824 | - 'EVT_desc' => array('LIKE', $search_string), |
|
1825 | - 'EVT_short_desc' => array('LIKE', $search_string), |
|
1826 | - ); |
|
1827 | - } |
|
1828 | - $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1829 | - $query_params = apply_filters( |
|
1830 | - 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1831 | - array( |
|
1832 | - $where, |
|
1833 | - 'limit' => $limit, |
|
1834 | - 'order_by' => $orderby, |
|
1835 | - 'order' => $order, |
|
1836 | - 'group_by' => 'EVT_ID', |
|
1837 | - ), |
|
1838 | - $this->_req_data |
|
1839 | - ); |
|
1840 | - //let's first check if we have special requests coming in. |
|
1841 | - if (isset($this->_req_data['active_status'])) { |
|
1842 | - switch ($this->_req_data['active_status']) { |
|
1843 | - case 'upcoming' : |
|
1844 | - return $EEME->get_upcoming_events($query_params, $count); |
|
1845 | - break; |
|
1846 | - case 'expired' : |
|
1847 | - return $EEME->get_expired_events($query_params, $count); |
|
1848 | - break; |
|
1849 | - case 'active' : |
|
1850 | - return $EEME->get_active_events($query_params, $count); |
|
1851 | - break; |
|
1852 | - case 'inactive' : |
|
1853 | - return $EEME->get_inactive_events($query_params, $count); |
|
1854 | - break; |
|
1855 | - } |
|
1856 | - } |
|
1857 | - $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1858 | - return $events; |
|
1859 | - } |
|
1860 | - |
|
1861 | - |
|
1862 | - |
|
1863 | - /** |
|
1864 | - * handling for WordPress CPT actions (trash, restore, delete) |
|
1865 | - * |
|
1866 | - * @param string $post_id |
|
1867 | - */ |
|
1868 | - public function trash_cpt_item($post_id) |
|
1869 | - { |
|
1870 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1871 | - $this->_trash_or_restore_event('trash', false); |
|
1872 | - } |
|
1873 | - |
|
1874 | - |
|
1875 | - |
|
1876 | - /** |
|
1877 | - * @param string $post_id |
|
1878 | - */ |
|
1879 | - public function restore_cpt_item($post_id) |
|
1880 | - { |
|
1881 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1882 | - $this->_trash_or_restore_event('draft', false); |
|
1883 | - } |
|
1884 | - |
|
1885 | - |
|
1886 | - |
|
1887 | - /** |
|
1888 | - * @param string $post_id |
|
1889 | - */ |
|
1890 | - public function delete_cpt_item($post_id) |
|
1891 | - { |
|
1892 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1893 | - $this->_delete_event(false); |
|
1894 | - } |
|
1895 | - |
|
1896 | - |
|
1897 | - |
|
1898 | - /** |
|
1899 | - * _trash_or_restore_event |
|
1900 | - * |
|
1901 | - * @access protected |
|
1902 | - * @param string $event_status |
|
1903 | - * @param bool $redirect_after |
|
1904 | - */ |
|
1905 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1906 | - { |
|
1907 | - //determine the event id and set to array. |
|
1908 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1909 | - // loop thru events |
|
1910 | - if ($EVT_ID) { |
|
1911 | - // clean status |
|
1912 | - $event_status = sanitize_key($event_status); |
|
1913 | - // grab status |
|
1914 | - if ( ! empty($event_status)) { |
|
1915 | - $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1916 | - } else { |
|
1917 | - $success = false; |
|
1918 | - $msg = esc_html__( |
|
1919 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1920 | - 'event_espresso' |
|
1921 | - ); |
|
1922 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1923 | - } |
|
1924 | - } else { |
|
1925 | - $success = false; |
|
1926 | - $msg = esc_html__( |
|
1927 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1928 | - 'event_espresso' |
|
1929 | - ); |
|
1930 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1931 | - } |
|
1932 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1933 | - if ($redirect_after) { |
|
1934 | - $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1935 | - } |
|
1936 | - } |
|
1937 | - |
|
1938 | - |
|
1939 | - |
|
1940 | - /** |
|
1941 | - * _trash_or_restore_events |
|
1942 | - * |
|
1943 | - * @access protected |
|
1944 | - * @param string $event_status |
|
1945 | - * @return void |
|
1946 | - */ |
|
1947 | - protected function _trash_or_restore_events($event_status = 'trash') |
|
1948 | - { |
|
1949 | - // clean status |
|
1950 | - $event_status = sanitize_key($event_status); |
|
1951 | - // grab status |
|
1952 | - if ( ! empty($event_status)) { |
|
1953 | - $success = true; |
|
1954 | - //determine the event id and set to array. |
|
1955 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1956 | - // loop thru events |
|
1957 | - foreach ($EVT_IDs as $EVT_ID) { |
|
1958 | - if ($EVT_ID = absint($EVT_ID)) { |
|
1959 | - $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1960 | - $success = $results !== false ? $success : false; |
|
1961 | - } else { |
|
1962 | - $msg = sprintf( |
|
1963 | - esc_html__( |
|
1964 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1965 | - 'event_espresso' |
|
1966 | - ), |
|
1967 | - $EVT_ID |
|
1968 | - ); |
|
1969 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1970 | - $success = false; |
|
1971 | - } |
|
1972 | - } |
|
1973 | - } else { |
|
1974 | - $success = false; |
|
1975 | - $msg = esc_html__( |
|
1976 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1977 | - 'event_espresso' |
|
1978 | - ); |
|
1979 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1980 | - } |
|
1981 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1982 | - $success = $success ? 2 : false; |
|
1983 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1984 | - $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1985 | - } |
|
1986 | - |
|
1987 | - |
|
1988 | - |
|
1989 | - /** |
|
1990 | - * _trash_or_restore_events |
|
1991 | - * |
|
1992 | - * @access private |
|
1993 | - * @param int $EVT_ID |
|
1994 | - * @param string $event_status |
|
1995 | - * @return bool |
|
1996 | - */ |
|
1997 | - private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1998 | - { |
|
1999 | - // grab event id |
|
2000 | - if ( ! $EVT_ID) { |
|
2001 | - $msg = esc_html__( |
|
2002 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2003 | - 'event_espresso' |
|
2004 | - ); |
|
2005 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2006 | - return false; |
|
2007 | - } |
|
2008 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2009 | - // clean status |
|
2010 | - $event_status = sanitize_key($event_status); |
|
2011 | - // grab status |
|
2012 | - if (empty($event_status)) { |
|
2013 | - $msg = esc_html__( |
|
2014 | - 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
2015 | - 'event_espresso' |
|
2016 | - ); |
|
2017 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2018 | - return false; |
|
2019 | - } |
|
2020 | - // was event trashed or restored ? |
|
2021 | - switch ($event_status) { |
|
2022 | - case 'draft' : |
|
2023 | - $action = 'restored from the trash'; |
|
2024 | - $hook = 'AHEE_event_restored_from_trash'; |
|
2025 | - break; |
|
2026 | - case 'trash' : |
|
2027 | - $action = 'moved to the trash'; |
|
2028 | - $hook = 'AHEE_event_moved_to_trash'; |
|
2029 | - break; |
|
2030 | - default : |
|
2031 | - $action = 'updated'; |
|
2032 | - $hook = false; |
|
2033 | - } |
|
2034 | - //use class to change status |
|
2035 | - $this->_cpt_model_obj->set_status($event_status); |
|
2036 | - $success = $this->_cpt_model_obj->save(); |
|
2037 | - if ($success === false) { |
|
2038 | - $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2039 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2040 | - return false; |
|
2041 | - } |
|
2042 | - if ($hook) { |
|
2043 | - do_action($hook); |
|
2044 | - } |
|
2045 | - return true; |
|
2046 | - } |
|
2047 | - |
|
2048 | - |
|
2049 | - |
|
2050 | - /** |
|
2051 | - * _delete_event |
|
2052 | - * |
|
2053 | - * @access protected |
|
2054 | - * @param bool $redirect_after |
|
2055 | - */ |
|
2056 | - protected function _delete_event($redirect_after = true) |
|
2057 | - { |
|
2058 | - //determine the event id and set to array. |
|
2059 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2060 | - $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2061 | - // loop thru events |
|
2062 | - if ($EVT_ID) { |
|
2063 | - $success = $this->_permanently_delete_event($EVT_ID); |
|
2064 | - // get list of events with no prices |
|
2065 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2066 | - // remove this event from the list of events with no prices |
|
2067 | - if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2068 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2069 | - } |
|
2070 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2071 | - } else { |
|
2072 | - $success = false; |
|
2073 | - $msg = esc_html__( |
|
2074 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2075 | - 'event_espresso' |
|
2076 | - ); |
|
2077 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2078 | - } |
|
2079 | - if ($redirect_after) { |
|
2080 | - $this->_redirect_after_action( |
|
2081 | - $success, |
|
2082 | - 'Event', |
|
2083 | - 'deleted', |
|
2084 | - array('action' => 'default', 'status' => 'trash') |
|
2085 | - ); |
|
2086 | - } |
|
2087 | - } |
|
2088 | - |
|
2089 | - |
|
2090 | - |
|
2091 | - /** |
|
2092 | - * _delete_events |
|
2093 | - * |
|
2094 | - * @access protected |
|
2095 | - * @return void |
|
2096 | - */ |
|
2097 | - protected function _delete_events() |
|
2098 | - { |
|
2099 | - $success = true; |
|
2100 | - // get list of events with no prices |
|
2101 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2102 | - //determine the event id and set to array. |
|
2103 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2104 | - // loop thru events |
|
2105 | - foreach ($EVT_IDs as $EVT_ID) { |
|
2106 | - $EVT_ID = absint($EVT_ID); |
|
2107 | - if ($EVT_ID) { |
|
2108 | - $results = $this->_permanently_delete_event($EVT_ID); |
|
2109 | - $success = $results !== false ? $success : false; |
|
2110 | - // remove this event from the list of events with no prices |
|
2111 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2112 | - } else { |
|
2113 | - $success = false; |
|
2114 | - $msg = esc_html__( |
|
2115 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2116 | - 'event_espresso' |
|
2117 | - ); |
|
2118 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2119 | - } |
|
2120 | - } |
|
2121 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2122 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2123 | - $success = $success ? 2 : false; |
|
2124 | - $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2125 | - } |
|
2126 | - |
|
2127 | - |
|
2128 | - |
|
2129 | - /** |
|
2130 | - * _permanently_delete_event |
|
2131 | - * |
|
2132 | - * @access private |
|
2133 | - * @param int $EVT_ID |
|
2134 | - * @return bool |
|
2135 | - */ |
|
2136 | - private function _permanently_delete_event($EVT_ID = 0) |
|
2137 | - { |
|
2138 | - // grab event id |
|
2139 | - if ( ! $EVT_ID) { |
|
2140 | - $msg = esc_html__( |
|
2141 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2142 | - 'event_espresso' |
|
2143 | - ); |
|
2144 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2145 | - return false; |
|
2146 | - } |
|
2147 | - if ( |
|
2148 | - ! $this->_cpt_model_obj instanceof EE_Event |
|
2149 | - || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2150 | - ) { |
|
2151 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2152 | - } |
|
2153 | - if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2154 | - return false; |
|
2155 | - } |
|
2156 | - //need to delete related tickets and prices first. |
|
2157 | - $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2158 | - foreach ($datetimes as $datetime) { |
|
2159 | - $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2160 | - $tickets = $datetime->get_many_related('Ticket'); |
|
2161 | - foreach ($tickets as $ticket) { |
|
2162 | - $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2163 | - $ticket->delete_related_permanently('Price'); |
|
2164 | - $ticket->delete_permanently(); |
|
2165 | - } |
|
2166 | - $datetime->delete(); |
|
2167 | - } |
|
2168 | - //what about related venues or terms? |
|
2169 | - $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2170 | - foreach ($venues as $venue) { |
|
2171 | - $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2172 | - } |
|
2173 | - //any attached question groups? |
|
2174 | - $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2175 | - if ( ! empty($question_groups)) { |
|
2176 | - foreach ($question_groups as $question_group) { |
|
2177 | - $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2178 | - } |
|
2179 | - } |
|
2180 | - //Message Template Groups |
|
2181 | - $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2182 | - /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2183 | - $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2184 | - foreach ($term_taxonomies as $term_taxonomy) { |
|
2185 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2186 | - } |
|
2187 | - $success = $this->_cpt_model_obj->delete_permanently(); |
|
2188 | - // did it all go as planned ? |
|
2189 | - if ($success) { |
|
2190 | - $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2191 | - EE_Error::add_success($msg); |
|
2192 | - } else { |
|
2193 | - $msg = sprintf( |
|
2194 | - esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2195 | - $EVT_ID |
|
2196 | - ); |
|
2197 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2198 | - return false; |
|
2199 | - } |
|
2200 | - do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2201 | - return true; |
|
2202 | - } |
|
2203 | - |
|
2204 | - |
|
2205 | - |
|
2206 | - /** |
|
2207 | - * get total number of events |
|
2208 | - * |
|
2209 | - * @access public |
|
2210 | - * @return int |
|
2211 | - */ |
|
2212 | - public function total_events() |
|
2213 | - { |
|
2214 | - $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2215 | - return $count; |
|
2216 | - } |
|
2217 | - |
|
2218 | - |
|
2219 | - |
|
2220 | - /** |
|
2221 | - * get total number of draft events |
|
2222 | - * |
|
2223 | - * @access public |
|
2224 | - * @return int |
|
2225 | - */ |
|
2226 | - public function total_events_draft() |
|
2227 | - { |
|
2228 | - $where = array( |
|
2229 | - 'status' => array('IN', array('draft', 'auto-draft')), |
|
2230 | - ); |
|
2231 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2232 | - return $count; |
|
2233 | - } |
|
2234 | - |
|
2235 | - |
|
2236 | - |
|
2237 | - /** |
|
2238 | - * get total number of trashed events |
|
2239 | - * |
|
2240 | - * @access public |
|
2241 | - * @return int |
|
2242 | - */ |
|
2243 | - public function total_trashed_events() |
|
2244 | - { |
|
2245 | - $where = array( |
|
2246 | - 'status' => 'trash', |
|
2247 | - ); |
|
2248 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2249 | - return $count; |
|
2250 | - } |
|
2251 | - |
|
2252 | - |
|
2253 | - |
|
2254 | - /** |
|
2255 | - * _default_event_settings |
|
2256 | - * This generates the Default Settings Tab |
|
2257 | - * |
|
2258 | - * @return void |
|
2259 | - */ |
|
2260 | - protected function _default_event_settings() |
|
2261 | - { |
|
2262 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
2263 | - $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2264 | - // exclude array |
|
2265 | - array( |
|
2266 | - EEM_Registration::status_id_cancelled, |
|
2267 | - EEM_Registration::status_id_declined, |
|
2268 | - EEM_Registration::status_id_incomplete, |
|
2269 | - EEM_Registration::status_id_wait_list, |
|
2270 | - ), |
|
2271 | - // translated |
|
2272 | - true |
|
2273 | - ); |
|
2274 | - $this->_template_args['default_reg_status'] = isset( |
|
2275 | - EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2276 | - ) |
|
2277 | - && array_key_exists( |
|
2278 | - EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2279 | - $this->_template_args['reg_status_array'] |
|
2280 | - ) |
|
2281 | - ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2282 | - : EEM_Registration::status_id_pending_payment; |
|
2283 | - $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2284 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2285 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2286 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2287 | - $this->_template_args, |
|
2288 | - true |
|
2289 | - ); |
|
2290 | - $this->display_admin_page_with_sidebar(); |
|
2291 | - } |
|
2292 | - |
|
2293 | - |
|
2294 | - |
|
2295 | - /** |
|
2296 | - * _update_default_event_settings |
|
2297 | - * |
|
2298 | - * @access protected |
|
2299 | - * @return void |
|
2300 | - */ |
|
2301 | - protected function _update_default_event_settings() |
|
2302 | - { |
|
2303 | - EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2304 | - ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2305 | - : EEM_Registration::status_id_pending_payment; |
|
2306 | - $what = 'Default Event Settings'; |
|
2307 | - $success = $this->_update_espresso_configuration( |
|
2308 | - $what, |
|
2309 | - EE_Config::instance(), |
|
2310 | - __FILE__, |
|
2311 | - __FUNCTION__, |
|
2312 | - __LINE__ |
|
2313 | - ); |
|
2314 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2315 | - } |
|
2316 | - |
|
2317 | - |
|
2318 | - |
|
2319 | - /************* Templates *************/ |
|
2320 | - protected function _template_settings() |
|
2321 | - { |
|
2322 | - $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2323 | - $this->_template_args['preview_img'] = '<img src="' |
|
2324 | - . EVENTS_ASSETS_URL |
|
2325 | - . DS |
|
2326 | - . 'images' |
|
2327 | - . DS |
|
2328 | - . 'caffeinated_template_features.jpg" alt="' |
|
2329 | - . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2330 | - . '" />'; |
|
2331 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2332 | - 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
2333 | - 'event_espresso' |
|
2334 | - ) . '</strong>'; |
|
2335 | - $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2336 | - } |
|
2337 | - |
|
2338 | - |
|
2339 | - /** Event Category Stuff **/ |
|
2340 | - /** |
|
2341 | - * set the _category property with the category object for the loaded page. |
|
2342 | - * |
|
2343 | - * @access private |
|
2344 | - * @return void |
|
2345 | - */ |
|
2346 | - private function _set_category_object() |
|
2347 | - { |
|
2348 | - if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2349 | - return; |
|
2350 | - } //already have the category object so get out. |
|
2351 | - //set default category object |
|
2352 | - $this->_set_empty_category_object(); |
|
2353 | - //only set if we've got an id |
|
2354 | - if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2355 | - return; |
|
2356 | - } |
|
2357 | - $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2358 | - $term = get_term($category_id, 'espresso_event_categories'); |
|
2359 | - if ( ! empty($term)) { |
|
2360 | - $this->_category->category_name = $term->name; |
|
2361 | - $this->_category->category_identifier = $term->slug; |
|
2362 | - $this->_category->category_desc = $term->description; |
|
2363 | - $this->_category->id = $term->term_id; |
|
2364 | - $this->_category->parent = $term->parent; |
|
2365 | - } |
|
2366 | - } |
|
2367 | - |
|
2368 | - |
|
2369 | - |
|
2370 | - private function _set_empty_category_object() |
|
2371 | - { |
|
2372 | - $this->_category = new stdClass(); |
|
2373 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2374 | - $this->_category->id = $this->_category->parent = 0; |
|
2375 | - } |
|
2376 | - |
|
2377 | - |
|
2378 | - |
|
2379 | - protected function _category_list_table() |
|
2380 | - { |
|
2381 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2382 | - $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2383 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2384 | - 'add_category', |
|
2385 | - 'add_category', |
|
2386 | - array(), |
|
2387 | - 'add-new-h2' |
|
2388 | - ); |
|
2389 | - $this->display_admin_list_table_page_with_sidebar(); |
|
2390 | - } |
|
2391 | - |
|
2392 | - |
|
2393 | - |
|
2394 | - /** |
|
2395 | - * @param $view |
|
2396 | - */ |
|
2397 | - protected function _category_details($view) |
|
2398 | - { |
|
2399 | - //load formatter helper |
|
2400 | - //load field generator helper |
|
2401 | - $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2402 | - $this->_set_add_edit_form_tags($route); |
|
2403 | - $this->_set_category_object(); |
|
2404 | - $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2405 | - $delete_action = 'delete_category'; |
|
2406 | - //custom redirect |
|
2407 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2408 | - array('action' => 'category_list'), |
|
2409 | - $this->_admin_base_url |
|
2410 | - ); |
|
2411 | - $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2412 | - //take care of contents |
|
2413 | - $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2414 | - $this->display_admin_page_with_sidebar(); |
|
2415 | - } |
|
2416 | - |
|
2417 | - |
|
2418 | - |
|
2419 | - /** |
|
2420 | - * @return mixed |
|
2421 | - */ |
|
2422 | - protected function _category_details_content() |
|
2423 | - { |
|
2424 | - $editor_args['category_desc'] = array( |
|
2425 | - 'type' => 'wp_editor', |
|
2426 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2427 | - 'class' => 'my_editor_custom', |
|
2428 | - 'wpeditor_args' => array('media_buttons' => false), |
|
2429 | - ); |
|
2430 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2431 | - $all_terms = get_terms( |
|
2432 | - array('espresso_event_categories'), |
|
2433 | - array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2434 | - ); |
|
2435 | - //setup category select for term parents. |
|
2436 | - $category_select_values[] = array( |
|
2437 | - 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2438 | - 'id' => 0, |
|
2439 | - ); |
|
2440 | - foreach ($all_terms as $term) { |
|
2441 | - $category_select_values[] = array( |
|
2442 | - 'text' => $term->name, |
|
2443 | - 'id' => $term->term_id, |
|
2444 | - ); |
|
2445 | - } |
|
2446 | - $category_select = EEH_Form_Fields::select_input( |
|
2447 | - 'category_parent', |
|
2448 | - $category_select_values, |
|
2449 | - $this->_category->parent |
|
2450 | - ); |
|
2451 | - $template_args = array( |
|
2452 | - 'category' => $this->_category, |
|
2453 | - 'category_select' => $category_select, |
|
2454 | - 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2455 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2456 | - 'disable' => '', |
|
2457 | - 'disabled_message' => false, |
|
2458 | - ); |
|
2459 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2460 | - return EEH_Template::display_template($template, $template_args, true); |
|
2461 | - } |
|
2462 | - |
|
2463 | - |
|
2464 | - |
|
2465 | - protected function _delete_categories() |
|
2466 | - { |
|
2467 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2468 | - : (array)$this->_req_data['category_id']; |
|
2469 | - foreach ($cat_ids as $cat_id) { |
|
2470 | - $this->_delete_category($cat_id); |
|
2471 | - } |
|
2472 | - //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2473 | - $query_args = array( |
|
2474 | - 'action' => 'category_list', |
|
2475 | - ); |
|
2476 | - $this->_redirect_after_action(0, '', '', $query_args); |
|
2477 | - } |
|
2478 | - |
|
2479 | - |
|
2480 | - |
|
2481 | - /** |
|
2482 | - * @param $cat_id |
|
2483 | - */ |
|
2484 | - protected function _delete_category($cat_id) |
|
2485 | - { |
|
2486 | - $cat_id = absint($cat_id); |
|
2487 | - wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2488 | - } |
|
2489 | - |
|
2490 | - |
|
2491 | - |
|
2492 | - /** |
|
2493 | - * @param $new_category |
|
2494 | - */ |
|
2495 | - protected function _insert_or_update_category($new_category) |
|
2496 | - { |
|
2497 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2498 | - $success = 0; //we already have a success message so lets not send another. |
|
2499 | - if ($cat_id) { |
|
2500 | - $query_args = array( |
|
2501 | - 'action' => 'edit_category', |
|
2502 | - 'EVT_CAT_ID' => $cat_id, |
|
2503 | - ); |
|
2504 | - } else { |
|
2505 | - $query_args = array('action' => 'add_category'); |
|
2506 | - } |
|
2507 | - $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2508 | - } |
|
2509 | - |
|
2510 | - |
|
2511 | - |
|
2512 | - /** |
|
2513 | - * @param bool $update |
|
2514 | - * @return bool|mixed|string |
|
2515 | - */ |
|
2516 | - private function _insert_category($update = false) |
|
2517 | - { |
|
2518 | - $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2519 | - $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2520 | - $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2521 | - $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2522 | - if (empty($category_name)) { |
|
2523 | - $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2524 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2525 | - return false; |
|
2526 | - } |
|
2527 | - $term_args = array( |
|
2528 | - 'name' => $category_name, |
|
2529 | - 'description' => $category_desc, |
|
2530 | - 'parent' => $category_parent, |
|
2531 | - ); |
|
2532 | - //was the category_identifier input disabled? |
|
2533 | - if (isset($this->_req_data['category_identifier'])) { |
|
2534 | - $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2535 | - } |
|
2536 | - $insert_ids = $update |
|
2537 | - ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2538 | - : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2539 | - if ( ! is_array($insert_ids)) { |
|
2540 | - $msg = esc_html__( |
|
2541 | - 'An error occurred and the category has not been saved to the database.', |
|
2542 | - 'event_espresso' |
|
2543 | - ); |
|
2544 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2545 | - } else { |
|
2546 | - $cat_id = $insert_ids['term_id']; |
|
2547 | - $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2548 | - EE_Error::add_success($msg); |
|
2549 | - } |
|
2550 | - return $cat_id; |
|
2551 | - } |
|
2552 | - |
|
2553 | - |
|
2554 | - |
|
2555 | - /** |
|
2556 | - * @param int $per_page |
|
2557 | - * @param int $current_page |
|
2558 | - * @param bool $count |
|
2559 | - * @return \EE_Base_Class[]|int |
|
2560 | - */ |
|
2561 | - public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2562 | - { |
|
2563 | - //testing term stuff |
|
2564 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2565 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2566 | - $limit = ($current_page - 1) * $per_page; |
|
2567 | - $where = array('taxonomy' => 'espresso_event_categories'); |
|
2568 | - if (isset($this->_req_data['s'])) { |
|
2569 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2570 | - $where['OR'] = array( |
|
2571 | - 'Term.name' => array('LIKE', $sstr), |
|
2572 | - 'description' => array('LIKE', $sstr), |
|
2573 | - ); |
|
2574 | - } |
|
2575 | - $query_params = array( |
|
2576 | - $where, |
|
2577 | - 'order_by' => array($orderby => $order), |
|
2578 | - 'limit' => $limit . ',' . $per_page, |
|
2579 | - 'force_join' => array('Term'), |
|
2580 | - ); |
|
2581 | - $categories = $count |
|
2582 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2583 | - : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2584 | - return $categories; |
|
2585 | - } |
|
2586 | - |
|
2587 | - |
|
2588 | - |
|
2589 | - /* end category stuff */ |
|
2590 | - /**************/ |
|
385 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
386 | + 'require_nonce' => false, |
|
387 | + ), |
|
388 | + 'default_event_settings' => array( |
|
389 | + 'nav' => array( |
|
390 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
391 | + 'order' => 40, |
|
392 | + ), |
|
393 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
394 | + 'labels' => array( |
|
395 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
396 | + ), |
|
397 | + 'help_tabs' => array( |
|
398 | + 'default_settings_help_tab' => array( |
|
399 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
400 | + 'filename' => 'events_default_settings', |
|
401 | + ), |
|
402 | + 'default_settings_status_help_tab' => array( |
|
403 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
404 | + 'filename' => 'events_default_settings_status', |
|
405 | + ), |
|
406 | + ), |
|
407 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
408 | + 'require_nonce' => false, |
|
409 | + ), |
|
410 | + //template settings |
|
411 | + 'template_settings' => array( |
|
412 | + 'nav' => array( |
|
413 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
414 | + 'order' => 30, |
|
415 | + ), |
|
416 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
417 | + 'help_tabs' => array( |
|
418 | + 'general_settings_templates_help_tab' => array( |
|
419 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
420 | + 'filename' => 'general_settings_templates', |
|
421 | + ), |
|
422 | + ), |
|
423 | + 'help_tour' => array('Templates_Help_Tour'), |
|
424 | + 'require_nonce' => false, |
|
425 | + ), |
|
426 | + //event category stuff |
|
427 | + 'add_category' => array( |
|
428 | + 'nav' => array( |
|
429 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
430 | + 'order' => 15, |
|
431 | + 'persistent' => false, |
|
432 | + ), |
|
433 | + 'help_tabs' => array( |
|
434 | + 'add_category_help_tab' => array( |
|
435 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
436 | + 'filename' => 'events_add_category', |
|
437 | + ), |
|
438 | + ), |
|
439 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
440 | + 'metaboxes' => array('_publish_post_box'), |
|
441 | + 'require_nonce' => false, |
|
442 | + ), |
|
443 | + 'edit_category' => array( |
|
444 | + 'nav' => array( |
|
445 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
446 | + 'order' => 15, |
|
447 | + 'persistent' => false, |
|
448 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
449 | + ? add_query_arg( |
|
450 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
451 | + $this->_current_page_view_url |
|
452 | + ) |
|
453 | + : $this->_admin_base_url, |
|
454 | + ), |
|
455 | + 'help_tabs' => array( |
|
456 | + 'edit_category_help_tab' => array( |
|
457 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
458 | + 'filename' => 'events_edit_category', |
|
459 | + ), |
|
460 | + ), |
|
461 | + /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
462 | + 'metaboxes' => array('_publish_post_box'), |
|
463 | + 'require_nonce' => false, |
|
464 | + ), |
|
465 | + 'category_list' => array( |
|
466 | + 'nav' => array( |
|
467 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
468 | + 'order' => 20, |
|
469 | + ), |
|
470 | + 'list_table' => 'Event_Categories_Admin_List_Table', |
|
471 | + 'help_tabs' => array( |
|
472 | + 'events_categories_help_tab' => array( |
|
473 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
474 | + 'filename' => 'events_categories', |
|
475 | + ), |
|
476 | + 'events_categories_table_column_headings_help_tab' => array( |
|
477 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
478 | + 'filename' => 'events_categories_table_column_headings', |
|
479 | + ), |
|
480 | + 'events_categories_view_help_tab' => array( |
|
481 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
482 | + 'filename' => 'events_categories_views', |
|
483 | + ), |
|
484 | + 'events_categories_other_help_tab' => array( |
|
485 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
486 | + 'filename' => 'events_categories_other', |
|
487 | + ), |
|
488 | + ), |
|
489 | + 'help_tour' => array( |
|
490 | + 'Event_Categories_Help_Tour', |
|
491 | + ), |
|
492 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
493 | + 'require_nonce' => false, |
|
494 | + ), |
|
495 | + ); |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + |
|
500 | + protected function _add_screen_options() |
|
501 | + { |
|
502 | + //todo |
|
503 | + } |
|
504 | + |
|
505 | + |
|
506 | + |
|
507 | + protected function _add_screen_options_default() |
|
508 | + { |
|
509 | + $this->_per_page_screen_option(); |
|
510 | + } |
|
511 | + |
|
512 | + |
|
513 | + |
|
514 | + protected function _add_screen_options_category_list() |
|
515 | + { |
|
516 | + $page_title = $this->_admin_page_title; |
|
517 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
518 | + $this->_per_page_screen_option(); |
|
519 | + $this->_admin_page_title = $page_title; |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + |
|
524 | + protected function _add_feature_pointers() |
|
525 | + { |
|
526 | + //todo |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + |
|
531 | + public function load_scripts_styles() |
|
532 | + { |
|
533 | + wp_register_style( |
|
534 | + 'events-admin-css', |
|
535 | + EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
536 | + array(), |
|
537 | + EVENT_ESPRESSO_VERSION |
|
538 | + ); |
|
539 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
540 | + wp_enqueue_style('events-admin-css'); |
|
541 | + wp_enqueue_style('ee-cat-admin'); |
|
542 | + //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
543 | + //registers for all views |
|
544 | + //scripts |
|
545 | + wp_register_script( |
|
546 | + 'event_editor_js', |
|
547 | + EVENTS_ASSETS_URL . 'event_editor.js', |
|
548 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
549 | + EVENT_ESPRESSO_VERSION, |
|
550 | + true |
|
551 | + ); |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * enqueuing scripts and styles specific to this view |
|
558 | + * |
|
559 | + * @return void |
|
560 | + */ |
|
561 | + public function load_scripts_styles_create_new() |
|
562 | + { |
|
563 | + $this->load_scripts_styles_edit(); |
|
564 | + } |
|
565 | + |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * enqueuing scripts and styles specific to this view |
|
570 | + * |
|
571 | + * @return void |
|
572 | + */ |
|
573 | + public function load_scripts_styles_edit() |
|
574 | + { |
|
575 | + //styles |
|
576 | + wp_enqueue_style('espresso-ui-theme'); |
|
577 | + wp_register_style( |
|
578 | + 'event-editor-css', |
|
579 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
580 | + array('ee-admin-css'), |
|
581 | + EVENT_ESPRESSO_VERSION |
|
582 | + ); |
|
583 | + wp_enqueue_style('event-editor-css'); |
|
584 | + //scripts |
|
585 | + wp_register_script( |
|
586 | + 'event-datetime-metabox', |
|
587 | + EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
588 | + array('event_editor_js', 'ee-datepicker'), |
|
589 | + EVENT_ESPRESSO_VERSION |
|
590 | + ); |
|
591 | + wp_enqueue_script('event-datetime-metabox'); |
|
592 | + } |
|
593 | + |
|
594 | + |
|
595 | + |
|
596 | + public function load_scripts_styles_add_category() |
|
597 | + { |
|
598 | + $this->load_scripts_styles_edit_category(); |
|
599 | + } |
|
600 | + |
|
601 | + |
|
602 | + |
|
603 | + public function load_scripts_styles_edit_category() |
|
604 | + { |
|
605 | + } |
|
606 | + |
|
607 | + |
|
608 | + |
|
609 | + protected function _set_list_table_views_category_list() |
|
610 | + { |
|
611 | + $this->_views = array( |
|
612 | + 'all' => array( |
|
613 | + 'slug' => 'all', |
|
614 | + 'label' => esc_html__('All', 'event_espresso'), |
|
615 | + 'count' => 0, |
|
616 | + 'bulk_action' => array( |
|
617 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
618 | + ), |
|
619 | + ), |
|
620 | + ); |
|
621 | + } |
|
622 | + |
|
623 | + |
|
624 | + |
|
625 | + public function admin_init() |
|
626 | + { |
|
627 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
628 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
629 | + 'event_espresso' |
|
630 | + ); |
|
631 | + } |
|
632 | + |
|
633 | + |
|
634 | + |
|
635 | + //nothing needed for events with these methods. |
|
636 | + public function admin_notices() |
|
637 | + { |
|
638 | + } |
|
639 | + |
|
640 | + |
|
641 | + |
|
642 | + public function admin_footer_scripts() |
|
643 | + { |
|
644 | + } |
|
645 | + |
|
646 | + |
|
647 | + |
|
648 | + /** |
|
649 | + * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
650 | + * warning (via EE_Error::add_error()); |
|
651 | + * |
|
652 | + * @param EE_Event $event Event object |
|
653 | + * @access public |
|
654 | + * @return void |
|
655 | + */ |
|
656 | + public function verify_event_edit($event = null) |
|
657 | + { |
|
658 | + // no event? |
|
659 | + if (empty($event)) { |
|
660 | + // set event |
|
661 | + $event = $this->_cpt_model_obj; |
|
662 | + } |
|
663 | + // STILL no event? |
|
664 | + if (empty ($event)) { |
|
665 | + return; |
|
666 | + } |
|
667 | + $orig_status = $event->status(); |
|
668 | + // first check if event is active. |
|
669 | + if ( |
|
670 | + $orig_status === EEM_Event::cancelled |
|
671 | + || $orig_status === EEM_Event::postponed |
|
672 | + || $event->is_expired() |
|
673 | + || $event->is_inactive() |
|
674 | + ) { |
|
675 | + return; |
|
676 | + } |
|
677 | + //made it here so it IS active... next check that any of the tickets are sold. |
|
678 | + if ($event->is_sold_out(true)) { |
|
679 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
680 | + EE_Error::add_attention( |
|
681 | + sprintf( |
|
682 | + esc_html__( |
|
683 | + 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
684 | + 'event_espresso' |
|
685 | + ), |
|
686 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
687 | + ) |
|
688 | + ); |
|
689 | + } |
|
690 | + return; |
|
691 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
692 | + EE_Error::add_attention( |
|
693 | + sprintf( |
|
694 | + esc_html__( |
|
695 | + 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
696 | + 'event_espresso' |
|
697 | + ), |
|
698 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
699 | + ) |
|
700 | + ); |
|
701 | + } |
|
702 | + //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
703 | + if ( ! $event->tickets_on_sale()) { |
|
704 | + return; |
|
705 | + } |
|
706 | + //made it here so show warning |
|
707 | + $this->_edit_event_warning(); |
|
708 | + } |
|
709 | + |
|
710 | + |
|
711 | + |
|
712 | + /** |
|
713 | + * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
714 | + * When needed, hook this into a EE_Error::add_error() notice. |
|
715 | + * |
|
716 | + * @access protected |
|
717 | + * @return void |
|
718 | + */ |
|
719 | + protected function _edit_event_warning() |
|
720 | + { |
|
721 | + // we don't want to add warnings during these requests |
|
722 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
723 | + return; |
|
724 | + } |
|
725 | + EE_Error::add_attention( |
|
726 | + esc_html__( |
|
727 | + 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
728 | + 'event_espresso' |
|
729 | + ) |
|
730 | + ); |
|
731 | + } |
|
732 | + |
|
733 | + |
|
734 | + |
|
735 | + /** |
|
736 | + * When a user is creating a new event, notify them if they haven't set their timezone. |
|
737 | + * Otherwise, do the normal logic |
|
738 | + * |
|
739 | + * @return string |
|
740 | + * @throws \EE_Error |
|
741 | + */ |
|
742 | + protected function _create_new_cpt_item() |
|
743 | + { |
|
744 | + $gmt_offset = get_option('gmt_offset'); |
|
745 | + //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
746 | + if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
747 | + EE_Error::add_attention( |
|
748 | + sprintf( |
|
749 | + __( |
|
750 | + 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.', |
|
751 | + 'event_espresso' |
|
752 | + ), |
|
753 | + '<a href="' . admin_url('options-general.php') . '">', |
|
754 | + '</a>' |
|
755 | + ), |
|
756 | + __FILE__, |
|
757 | + __FUNCTION__, |
|
758 | + __LINE__ |
|
759 | + ); |
|
760 | + } |
|
761 | + return parent::_create_new_cpt_item(); |
|
762 | + } |
|
763 | + |
|
764 | + |
|
765 | + |
|
766 | + protected function _set_list_table_views_default() |
|
767 | + { |
|
768 | + $this->_views = array( |
|
769 | + 'all' => array( |
|
770 | + 'slug' => 'all', |
|
771 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
772 | + 'count' => 0, |
|
773 | + 'bulk_action' => array( |
|
774 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
775 | + ), |
|
776 | + ), |
|
777 | + 'draft' => array( |
|
778 | + 'slug' => 'draft', |
|
779 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
780 | + 'count' => 0, |
|
781 | + 'bulk_action' => array( |
|
782 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
783 | + ), |
|
784 | + ), |
|
785 | + ); |
|
786 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
787 | + $this->_views['trash'] = array( |
|
788 | + 'slug' => 'trash', |
|
789 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
790 | + 'count' => 0, |
|
791 | + 'bulk_action' => array( |
|
792 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
793 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
794 | + ), |
|
795 | + ); |
|
796 | + } |
|
797 | + } |
|
798 | + |
|
799 | + |
|
800 | + |
|
801 | + /** |
|
802 | + * @return array |
|
803 | + */ |
|
804 | + protected function _event_legend_items() |
|
805 | + { |
|
806 | + $items = array( |
|
807 | + 'view_details' => array( |
|
808 | + 'class' => 'dashicons dashicons-search', |
|
809 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
810 | + ), |
|
811 | + 'edit_event' => array( |
|
812 | + 'class' => 'ee-icon ee-icon-calendar-edit', |
|
813 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
814 | + ), |
|
815 | + 'view_attendees' => array( |
|
816 | + 'class' => 'dashicons dashicons-groups', |
|
817 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
818 | + ), |
|
819 | + ); |
|
820 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
821 | + $statuses = array( |
|
822 | + 'sold_out_status' => array( |
|
823 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
824 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
825 | + ), |
|
826 | + 'active_status' => array( |
|
827 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
828 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
829 | + ), |
|
830 | + 'upcoming_status' => array( |
|
831 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
832 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
833 | + ), |
|
834 | + 'postponed_status' => array( |
|
835 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
836 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
837 | + ), |
|
838 | + 'cancelled_status' => array( |
|
839 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
840 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
841 | + ), |
|
842 | + 'expired_status' => array( |
|
843 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
844 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
845 | + ), |
|
846 | + 'inactive_status' => array( |
|
847 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
848 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
849 | + ), |
|
850 | + ); |
|
851 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
852 | + return array_merge($items, $statuses); |
|
853 | + } |
|
854 | + |
|
855 | + |
|
856 | + |
|
857 | + /** |
|
858 | + * _event_model |
|
859 | + * |
|
860 | + * @return EEM_Event |
|
861 | + */ |
|
862 | + private function _event_model() |
|
863 | + { |
|
864 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
865 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
866 | + } |
|
867 | + return $this->_event_model; |
|
868 | + } |
|
869 | + |
|
870 | + |
|
871 | + |
|
872 | + /** |
|
873 | + * Adds extra buttons to the WP CPT permalink field row. |
|
874 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
875 | + * |
|
876 | + * @param string $return the current html |
|
877 | + * @param int $id the post id for the page |
|
878 | + * @param string $new_title What the title is |
|
879 | + * @param string $new_slug what the slug is |
|
880 | + * @return string The new html string for the permalink area |
|
881 | + */ |
|
882 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
883 | + { |
|
884 | + //make sure this is only when editing |
|
885 | + if ( ! empty($id)) { |
|
886 | + $post = get_post($id); |
|
887 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
888 | + . esc_html__('Shortcode', 'event_espresso') |
|
889 | + . '</a> '; |
|
890 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
891 | + . $post->ID |
|
892 | + . ']">'; |
|
893 | + } |
|
894 | + return $return; |
|
895 | + } |
|
896 | + |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * _events_overview_list_table |
|
901 | + * This contains the logic for showing the events_overview list |
|
902 | + * |
|
903 | + * @access protected |
|
904 | + * @return void |
|
905 | + * @throws \EE_Error |
|
906 | + */ |
|
907 | + protected function _events_overview_list_table() |
|
908 | + { |
|
909 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
910 | + $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
911 | + ? (array)$this->_template_args['after_list_table'] |
|
912 | + : array(); |
|
913 | + $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
914 | + . EEH_Template::get_button_or_link( |
|
915 | + get_post_type_archive_link('espresso_events'), |
|
916 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
917 | + 'button' |
|
918 | + ); |
|
919 | + $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
920 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
921 | + 'create_new', |
|
922 | + 'add', |
|
923 | + array(), |
|
924 | + 'add-new-h2' |
|
925 | + ); |
|
926 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
927 | + } |
|
928 | + |
|
929 | + |
|
930 | + |
|
931 | + /** |
|
932 | + * this allows for extra misc actions in the default WP publish box |
|
933 | + * |
|
934 | + * @return void |
|
935 | + */ |
|
936 | + public function extra_misc_actions_publish_box() |
|
937 | + { |
|
938 | + $this->_generate_publish_box_extra_content(); |
|
939 | + } |
|
940 | + |
|
941 | + |
|
942 | + |
|
943 | + /** |
|
944 | + * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
945 | + * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
946 | + * data. |
|
947 | + * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
948 | + * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
949 | + * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
950 | + * you handle this accordingly. |
|
951 | + * |
|
952 | + * @access protected |
|
953 | + * @abstract |
|
954 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
955 | + * @param object $post The post object of the cpt that was saved. |
|
956 | + * @return void |
|
957 | + */ |
|
958 | + protected function _insert_update_cpt_item($post_id, $post) |
|
959 | + { |
|
960 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
961 | + //get out we're not processing an event save. |
|
962 | + return; |
|
963 | + } |
|
964 | + $event_values = array( |
|
965 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
966 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
967 | + 'EVT_additional_limit' => min( |
|
968 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
969 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
970 | + ), |
|
971 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
972 | + ? $this->_req_data['EVT_default_registration_status'] |
|
973 | + : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
974 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
975 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
976 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
977 | + ? $this->_req_data['timezone_string'] : null, |
|
978 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
979 | + ? $this->_req_data['externalURL'] : null, |
|
980 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
981 | + ? $this->_req_data['event_phone'] : null, |
|
982 | + ); |
|
983 | + //update event |
|
984 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
985 | + //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_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! |
|
986 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
987 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
988 | + //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
989 | + $event_update_callbacks = apply_filters( |
|
990 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
991 | + array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
992 | + ); |
|
993 | + $att_success = true; |
|
994 | + foreach ($event_update_callbacks as $e_callback) { |
|
995 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
996 | + $att_success = ! $att_success ? $att_success |
|
997 | + : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
998 | + } |
|
999 | + //any errors? |
|
1000 | + if ($success && false === $att_success) { |
|
1001 | + EE_Error::add_error( |
|
1002 | + esc_html__( |
|
1003 | + 'Event Details saved successfully but something went wrong with saving attachments.', |
|
1004 | + 'event_espresso' |
|
1005 | + ), |
|
1006 | + __FILE__, |
|
1007 | + __FUNCTION__, |
|
1008 | + __LINE__ |
|
1009 | + ); |
|
1010 | + } else if ($success === false) { |
|
1011 | + EE_Error::add_error( |
|
1012 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
1013 | + __FILE__, |
|
1014 | + __FUNCTION__, |
|
1015 | + __LINE__ |
|
1016 | + ); |
|
1017 | + } |
|
1018 | + } |
|
1019 | + |
|
1020 | + |
|
1021 | + |
|
1022 | + /** |
|
1023 | + * @see parent::restore_item() |
|
1024 | + * @param int $post_id |
|
1025 | + * @param int $revision_id |
|
1026 | + */ |
|
1027 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
1028 | + { |
|
1029 | + //copy existing event meta to new post |
|
1030 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1031 | + if ($post_evt instanceof EE_Event) { |
|
1032 | + //meta revision restore |
|
1033 | + $post_evt->restore_revision($revision_id); |
|
1034 | + //related objs restore |
|
1035 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1036 | + } |
|
1037 | + } |
|
1038 | + |
|
1039 | + |
|
1040 | + |
|
1041 | + /** |
|
1042 | + * Attach the venue to the Event |
|
1043 | + * |
|
1044 | + * @param \EE_Event $evtobj Event Object to add the venue to |
|
1045 | + * @param array $data The request data from the form |
|
1046 | + * @return bool Success or fail. |
|
1047 | + */ |
|
1048 | + protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1049 | + { |
|
1050 | + require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1051 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1052 | + $rows_affected = null; |
|
1053 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1054 | + // very important. If we don't have a venue name... |
|
1055 | + // then we'll get out because not necessary to create empty venue |
|
1056 | + if (empty($data['venue_title'])) { |
|
1057 | + return false; |
|
1058 | + } |
|
1059 | + $venue_array = array( |
|
1060 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1061 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1062 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1063 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1064 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1065 | + : null, |
|
1066 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1067 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1068 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1069 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1070 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1071 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1072 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1073 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1074 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1075 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1076 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1077 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1078 | + 'status' => 'publish', |
|
1079 | + ); |
|
1080 | + //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1081 | + if ( ! empty($venue_id)) { |
|
1082 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1083 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1084 | + //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
1085 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1086 | + return $rows_affected > 0 ? true : false; |
|
1087 | + } else { |
|
1088 | + //we insert the venue |
|
1089 | + $venue_id = $venue_model->insert($venue_array); |
|
1090 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1091 | + return ! empty($venue_id) ? true : false; |
|
1092 | + } |
|
1093 | + //when we have the ancestor come in it's already been handled by the revision save. |
|
1094 | + } |
|
1095 | + |
|
1096 | + |
|
1097 | + |
|
1098 | + /** |
|
1099 | + * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1100 | + * |
|
1101 | + * @param EE_Event $evtobj The Event object we're attaching data to |
|
1102 | + * @param array $data The request data from the form |
|
1103 | + * @return array |
|
1104 | + */ |
|
1105 | + protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1106 | + { |
|
1107 | + $success = true; |
|
1108 | + $saved_dtt = null; |
|
1109 | + $saved_tickets = array(); |
|
1110 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1111 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1112 | + //trim all values to ensure any excess whitespace is removed. |
|
1113 | + $dtt = array_map('trim', $dtt); |
|
1114 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1115 | + : $dtt['DTT_EVT_start']; |
|
1116 | + $datetime_values = array( |
|
1117 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1118 | + 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1119 | + 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1120 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1121 | + 'DTT_order' => $row, |
|
1122 | + ); |
|
1123 | + //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
1124 | + if ( ! empty($dtt['DTT_ID'])) { |
|
1125 | + $DTM = EE_Registry::instance() |
|
1126 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1127 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
1128 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1129 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1130 | + foreach ($datetime_values as $field => $value) { |
|
1131 | + $DTM->set($field, $value); |
|
1132 | + } |
|
1133 | + //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
1134 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
1135 | + } else { |
|
1136 | + $DTM = EE_Registry::instance()->load_class( |
|
1137 | + 'Datetime', |
|
1138 | + array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
1139 | + false, |
|
1140 | + false |
|
1141 | + ); |
|
1142 | + foreach ($datetime_values as $field => $value) { |
|
1143 | + $DTM->set($field, $value); |
|
1144 | + } |
|
1145 | + } |
|
1146 | + $DTM->save(); |
|
1147 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1148 | + //load DTT helper |
|
1149 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1150 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1151 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1152 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1153 | + $DTT->save(); |
|
1154 | + } |
|
1155 | + //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
1156 | + $saved_dtt = $DTT; |
|
1157 | + $success = ! $success ? $success : $DTT; |
|
1158 | + //if ANY of these updates fail then we want the appropriate global error message. |
|
1159 | + // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1160 | + } |
|
1161 | + //no dtts get deleted so we don't do any of that logic here. |
|
1162 | + //update tickets next |
|
1163 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1164 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1165 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1166 | + $update_prices = false; |
|
1167 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1168 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1169 | + // trim inputs to ensure any excess whitespace is removed. |
|
1170 | + $tkt = array_map('trim', $tkt); |
|
1171 | + if (empty($tkt['TKT_start_date'])) { |
|
1172 | + //let's use now in the set timezone. |
|
1173 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1174 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1175 | + } |
|
1176 | + if (empty($tkt['TKT_end_date'])) { |
|
1177 | + //use the start date of the first datetime |
|
1178 | + $dtt = $evtobj->first_datetime(); |
|
1179 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1180 | + $incoming_date_formats[0], |
|
1181 | + $incoming_date_formats[1] |
|
1182 | + ); |
|
1183 | + } |
|
1184 | + $TKT_values = array( |
|
1185 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1186 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1187 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1188 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1189 | + 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1190 | + 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1191 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1192 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1193 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1194 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1195 | + 'TKT_row' => $row, |
|
1196 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1197 | + 'TKT_price' => $ticket_price, |
|
1198 | + ); |
|
1199 | + //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
1200 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1201 | + $TKT_values['TKT_ID'] = 0; |
|
1202 | + $TKT_values['TKT_is_default'] = 0; |
|
1203 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1204 | + $update_prices = true; |
|
1205 | + } |
|
1206 | + //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1207 | + //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
1208 | + //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
1209 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1210 | + $TKT = EE_Registry::instance() |
|
1211 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1212 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
1213 | + if ($TKT instanceof EE_Ticket) { |
|
1214 | + $ticket_sold = $TKT->count_related( |
|
1215 | + 'Registration', |
|
1216 | + array( |
|
1217 | + array( |
|
1218 | + 'STS_ID' => array( |
|
1219 | + 'NOT IN', |
|
1220 | + array(EEM_Registration::status_id_incomplete), |
|
1221 | + ), |
|
1222 | + ), |
|
1223 | + ) |
|
1224 | + ) > 0 ? true : false; |
|
1225 | + //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
1226 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1227 | + && ! $TKT->get( |
|
1228 | + 'TKT_deleted' |
|
1229 | + ) ? true : false; |
|
1230 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1231 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1232 | + //set new values |
|
1233 | + foreach ($TKT_values as $field => $value) { |
|
1234 | + if ($field == 'TKT_qty') { |
|
1235 | + $TKT->set_qty($value); |
|
1236 | + } else { |
|
1237 | + $TKT->set($field, $value); |
|
1238 | + } |
|
1239 | + } |
|
1240 | + //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1241 | + if ($create_new_TKT) { |
|
1242 | + //archive the old ticket first |
|
1243 | + $TKT->set('TKT_deleted', 1); |
|
1244 | + $TKT->save(); |
|
1245 | + //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1246 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1247 | + //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
1248 | + $TKT = clone $TKT; |
|
1249 | + $TKT->set('TKT_ID', 0); |
|
1250 | + $TKT->set('TKT_deleted', 0); |
|
1251 | + $TKT->set('TKT_price', $ticket_price); |
|
1252 | + $TKT->set('TKT_sold', 0); |
|
1253 | + //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1254 | + $update_prices = true; |
|
1255 | + } |
|
1256 | + //make sure price is set if it hasn't been already |
|
1257 | + $TKT->set('TKT_price', $ticket_price); |
|
1258 | + } |
|
1259 | + } else { |
|
1260 | + //no TKT_id so a new TKT |
|
1261 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1262 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1263 | + if ($TKT instanceof EE_Ticket) { |
|
1264 | + //need to reset values to properly account for the date formats |
|
1265 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1266 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1267 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1268 | + //set new values |
|
1269 | + foreach ($TKT_values as $field => $value) { |
|
1270 | + if ($field == 'TKT_qty') { |
|
1271 | + $TKT->set_qty($value); |
|
1272 | + } else { |
|
1273 | + $TKT->set($field, $value); |
|
1274 | + } |
|
1275 | + } |
|
1276 | + $update_prices = true; |
|
1277 | + } |
|
1278 | + } |
|
1279 | + // cap ticket qty by datetime reg limits |
|
1280 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1281 | + //update ticket. |
|
1282 | + $TKT->save(); |
|
1283 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
1284 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1285 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1286 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1287 | + $TKT->save(); |
|
1288 | + } |
|
1289 | + //initially let's add the ticket to the dtt |
|
1290 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1291 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1292 | + //add prices to ticket |
|
1293 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1294 | + } |
|
1295 | + //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
1296 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1297 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1298 | + foreach ($tickets_removed as $id) { |
|
1299 | + $id = absint($id); |
|
1300 | + //get the ticket for this id |
|
1301 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1302 | + //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
1303 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1304 | + foreach ($dtts as $dtt) { |
|
1305 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1306 | + } |
|
1307 | + //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
1308 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
1309 | + //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1310 | + $tkt_to_remove->delete_permanently(); |
|
1311 | + } |
|
1312 | + return array($saved_dtt, $saved_tickets); |
|
1313 | + } |
|
1314 | + |
|
1315 | + |
|
1316 | + |
|
1317 | + /** |
|
1318 | + * This attaches a list of given prices to a ticket. |
|
1319 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1320 | + * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1321 | + * price info and prices are automatically "archived" via the ticket. |
|
1322 | + * |
|
1323 | + * @access private |
|
1324 | + * @param array $prices Array of prices from the form. |
|
1325 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1326 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1327 | + * @return void |
|
1328 | + */ |
|
1329 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1330 | + { |
|
1331 | + foreach ($prices as $row => $prc) { |
|
1332 | + $PRC_values = array( |
|
1333 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1334 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1335 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1336 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1337 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1338 | + 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1339 | + 'PRC_order' => $row, |
|
1340 | + ); |
|
1341 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1342 | + $PRC_values['PRC_ID'] = 0; |
|
1343 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1344 | + } else { |
|
1345 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1346 | + //update this price with new values |
|
1347 | + foreach ($PRC_values as $field => $newprc) { |
|
1348 | + $PRC->set($field, $newprc); |
|
1349 | + } |
|
1350 | + $PRC->save(); |
|
1351 | + } |
|
1352 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1353 | + } |
|
1354 | + } |
|
1355 | + |
|
1356 | + |
|
1357 | + |
|
1358 | + /** |
|
1359 | + * Add in our autosave ajax handlers |
|
1360 | + * |
|
1361 | + * @return void |
|
1362 | + */ |
|
1363 | + protected function _ee_autosave_create_new() |
|
1364 | + { |
|
1365 | + // $this->_ee_autosave_edit(); |
|
1366 | + } |
|
1367 | + |
|
1368 | + |
|
1369 | + |
|
1370 | + protected function _ee_autosave_edit() |
|
1371 | + { |
|
1372 | + return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1373 | + } |
|
1374 | + |
|
1375 | + |
|
1376 | + |
|
1377 | + /** |
|
1378 | + * _generate_publish_box_extra_content |
|
1379 | + * |
|
1380 | + * @access private |
|
1381 | + * @return void |
|
1382 | + */ |
|
1383 | + private function _generate_publish_box_extra_content() |
|
1384 | + { |
|
1385 | + //load formatter helper |
|
1386 | + //args for getting related registrations |
|
1387 | + $approved_query_args = array( |
|
1388 | + array( |
|
1389 | + 'REG_deleted' => 0, |
|
1390 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
1391 | + ), |
|
1392 | + ); |
|
1393 | + $not_approved_query_args = array( |
|
1394 | + array( |
|
1395 | + 'REG_deleted' => 0, |
|
1396 | + 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1397 | + ), |
|
1398 | + ); |
|
1399 | + $pending_payment_query_args = array( |
|
1400 | + array( |
|
1401 | + 'REG_deleted' => 0, |
|
1402 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1403 | + ), |
|
1404 | + ); |
|
1405 | + // publish box |
|
1406 | + $publish_box_extra_args = array( |
|
1407 | + 'view_approved_reg_url' => add_query_arg( |
|
1408 | + array( |
|
1409 | + 'action' => 'default', |
|
1410 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1411 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1412 | + ), |
|
1413 | + REG_ADMIN_URL |
|
1414 | + ), |
|
1415 | + 'view_not_approved_reg_url' => add_query_arg( |
|
1416 | + array( |
|
1417 | + 'action' => 'default', |
|
1418 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1419 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1420 | + ), |
|
1421 | + REG_ADMIN_URL |
|
1422 | + ), |
|
1423 | + 'view_pending_payment_reg_url' => add_query_arg( |
|
1424 | + array( |
|
1425 | + 'action' => 'default', |
|
1426 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1427 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1428 | + ), |
|
1429 | + REG_ADMIN_URL |
|
1430 | + ), |
|
1431 | + 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1432 | + 'Registration', |
|
1433 | + $approved_query_args |
|
1434 | + ), |
|
1435 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1436 | + 'Registration', |
|
1437 | + $not_approved_query_args |
|
1438 | + ), |
|
1439 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1440 | + 'Registration', |
|
1441 | + $pending_payment_query_args |
|
1442 | + ), |
|
1443 | + 'misc_pub_section_class' => apply_filters( |
|
1444 | + 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1445 | + 'misc-pub-section' |
|
1446 | + ), |
|
1447 | + //'email_attendees_url' => add_query_arg( |
|
1448 | + // array( |
|
1449 | + // 'event_admin_reports' => 'event_newsletter', |
|
1450 | + // 'event_id' => $this->_cpt_model_obj->id |
|
1451 | + // ), |
|
1452 | + // 'admin.php?page=espresso_registrations' |
|
1453 | + //), |
|
1454 | + ); |
|
1455 | + ob_start(); |
|
1456 | + do_action( |
|
1457 | + 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1458 | + $this->_cpt_model_obj |
|
1459 | + ); |
|
1460 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1461 | + // load template |
|
1462 | + EEH_Template::display_template( |
|
1463 | + EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1464 | + $publish_box_extra_args |
|
1465 | + ); |
|
1466 | + } |
|
1467 | + |
|
1468 | + |
|
1469 | + |
|
1470 | + /** |
|
1471 | + * This just returns whatever is set as the _event object property |
|
1472 | + * //todo this will become obsolete once the models are in place |
|
1473 | + * |
|
1474 | + * @return object |
|
1475 | + */ |
|
1476 | + public function get_event_object() |
|
1477 | + { |
|
1478 | + return $this->_cpt_model_obj; |
|
1479 | + } |
|
1480 | + |
|
1481 | + |
|
1482 | + |
|
1483 | + |
|
1484 | + /** METABOXES * */ |
|
1485 | + /** |
|
1486 | + * _register_event_editor_meta_boxes |
|
1487 | + * add all metaboxes related to the event_editor |
|
1488 | + * |
|
1489 | + * @return void |
|
1490 | + */ |
|
1491 | + protected function _register_event_editor_meta_boxes() |
|
1492 | + { |
|
1493 | + $this->verify_cpt_object(); |
|
1494 | + add_meta_box( |
|
1495 | + 'espresso_event_editor_tickets', |
|
1496 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1497 | + array($this, 'ticket_metabox'), |
|
1498 | + $this->page_slug, |
|
1499 | + 'normal', |
|
1500 | + 'high' |
|
1501 | + ); |
|
1502 | + add_meta_box( |
|
1503 | + 'espresso_event_editor_event_options', |
|
1504 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
1505 | + array($this, 'registration_options_meta_box'), |
|
1506 | + $this->page_slug, |
|
1507 | + 'side', |
|
1508 | + 'default' |
|
1509 | + ); |
|
1510 | + // NOTE: if you're looking for other metaboxes in here, |
|
1511 | + // where a metabox has a related management page in the admin |
|
1512 | + // you will find it setup in the related management page's "_Hooks" file. |
|
1513 | + // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1514 | + } |
|
1515 | + |
|
1516 | + |
|
1517 | + |
|
1518 | + public function ticket_metabox() |
|
1519 | + { |
|
1520 | + $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1521 | + //defaults for template args |
|
1522 | + $template_args = array( |
|
1523 | + 'existing_datetime_ids' => '', |
|
1524 | + 'event_datetime_help_link' => '', |
|
1525 | + 'ticket_options_help_link' => '', |
|
1526 | + 'time' => null, |
|
1527 | + 'ticket_rows' => '', |
|
1528 | + 'existing_ticket_ids' => '', |
|
1529 | + 'total_ticket_rows' => 1, |
|
1530 | + 'ticket_js_structure' => '', |
|
1531 | + 'trash_icon' => 'ee-lock-icon', |
|
1532 | + 'disabled' => '', |
|
1533 | + ); |
|
1534 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1535 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1536 | + /** |
|
1537 | + * 1. Start with retrieving Datetimes |
|
1538 | + * 2. Fore each datetime get related tickets |
|
1539 | + * 3. For each ticket get related prices |
|
1540 | + */ |
|
1541 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1542 | + /** @type EE_Datetime $first_datetime */ |
|
1543 | + $first_datetime = reset($times); |
|
1544 | + //do we get related tickets? |
|
1545 | + if ($first_datetime instanceof EE_Datetime |
|
1546 | + && $first_datetime->ID() !== 0 |
|
1547 | + ) { |
|
1548 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1549 | + $template_args['time'] = $first_datetime; |
|
1550 | + $related_tickets = $first_datetime->tickets( |
|
1551 | + array( |
|
1552 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1553 | + 'default_where_conditions' => 'none', |
|
1554 | + ) |
|
1555 | + ); |
|
1556 | + if ( ! empty($related_tickets)) { |
|
1557 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
1558 | + $row = 0; |
|
1559 | + foreach ($related_tickets as $ticket) { |
|
1560 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1561 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1562 | + $row++; |
|
1563 | + } |
|
1564 | + } else { |
|
1565 | + $template_args['total_ticket_rows'] = 1; |
|
1566 | + /** @type EE_Ticket $ticket */ |
|
1567 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1568 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1569 | + } |
|
1570 | + } else { |
|
1571 | + $template_args['time'] = $times[0]; |
|
1572 | + /** @type EE_Ticket $ticket */ |
|
1573 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1574 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1575 | + // NOTE: we're just sending the first default row |
|
1576 | + // (decaf can't manage default tickets so this should be sufficient); |
|
1577 | + } |
|
1578 | + $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1579 | + 'event_editor_event_datetimes_help_tab' |
|
1580 | + ); |
|
1581 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1582 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1583 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1584 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1585 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1586 | + true |
|
1587 | + ); |
|
1588 | + $template = apply_filters( |
|
1589 | + 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1590 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1591 | + ); |
|
1592 | + EEH_Template::display_template($template, $template_args); |
|
1593 | + } |
|
1594 | + |
|
1595 | + |
|
1596 | + |
|
1597 | + /** |
|
1598 | + * Setup an individual ticket form for the decaf event editor page |
|
1599 | + * |
|
1600 | + * @access private |
|
1601 | + * @param EE_Ticket $ticket the ticket object |
|
1602 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1603 | + * @param int $row |
|
1604 | + * @return string generated html for the ticket row. |
|
1605 | + */ |
|
1606 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1607 | + { |
|
1608 | + $template_args = array( |
|
1609 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1610 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1611 | + : '', |
|
1612 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1613 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1614 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
1615 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1616 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1617 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1618 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1619 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1620 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1621 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1622 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1623 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1624 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1625 | + : ' disabled=disabled', |
|
1626 | + ); |
|
1627 | + $price = $ticket->ID() !== 0 |
|
1628 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1629 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1630 | + $price_args = array( |
|
1631 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1632 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
1633 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
1634 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
1635 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1636 | + ); |
|
1637 | + //make sure we have default start and end dates if skeleton |
|
1638 | + //handle rows that should NOT be empty |
|
1639 | + if (empty($template_args['TKT_start_date'])) { |
|
1640 | + //if empty then the start date will be now. |
|
1641 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1642 | + } |
|
1643 | + if (empty($template_args['TKT_end_date'])) { |
|
1644 | + //get the earliest datetime (if present); |
|
1645 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1646 | + ? $this->_cpt_model_obj->get_first_related( |
|
1647 | + 'Datetime', |
|
1648 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1649 | + ) |
|
1650 | + : null; |
|
1651 | + if ( ! empty($earliest_dtt)) { |
|
1652 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1653 | + } else { |
|
1654 | + $template_args['TKT_end_date'] = date( |
|
1655 | + 'Y-m-d h:i a', |
|
1656 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1657 | + ); |
|
1658 | + } |
|
1659 | + } |
|
1660 | + $template_args = array_merge($template_args, $price_args); |
|
1661 | + $template = apply_filters( |
|
1662 | + 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1663 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1664 | + $ticket |
|
1665 | + ); |
|
1666 | + return EEH_Template::display_template($template, $template_args, true); |
|
1667 | + } |
|
1668 | + |
|
1669 | + |
|
1670 | + |
|
1671 | + public function registration_options_meta_box() |
|
1672 | + { |
|
1673 | + $yes_no_values = array( |
|
1674 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1675 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1676 | + ); |
|
1677 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1678 | + array( |
|
1679 | + EEM_Registration::status_id_cancelled, |
|
1680 | + EEM_Registration::status_id_declined, |
|
1681 | + EEM_Registration::status_id_incomplete, |
|
1682 | + ), |
|
1683 | + true |
|
1684 | + ); |
|
1685 | + //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1686 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
1687 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1688 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1689 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1690 | + 'default_reg_status', |
|
1691 | + $default_reg_status_values, |
|
1692 | + $this->_cpt_model_obj->default_registration_status() |
|
1693 | + ); |
|
1694 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1695 | + 'display_desc', |
|
1696 | + $yes_no_values, |
|
1697 | + $this->_cpt_model_obj->display_description() |
|
1698 | + ); |
|
1699 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1700 | + 'display_ticket_selector', |
|
1701 | + $yes_no_values, |
|
1702 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
1703 | + '', |
|
1704 | + '', |
|
1705 | + false |
|
1706 | + ); |
|
1707 | + $template_args['additional_registration_options'] = apply_filters( |
|
1708 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1709 | + '', |
|
1710 | + $template_args, |
|
1711 | + $yes_no_values, |
|
1712 | + $default_reg_status_values |
|
1713 | + ); |
|
1714 | + EEH_Template::display_template( |
|
1715 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1716 | + $template_args |
|
1717 | + ); |
|
1718 | + } |
|
1719 | + |
|
1720 | + |
|
1721 | + |
|
1722 | + /** |
|
1723 | + * _get_events() |
|
1724 | + * This method simply returns all the events (for the given _view and paging) |
|
1725 | + * |
|
1726 | + * @access public |
|
1727 | + * @param int $per_page count of items per page (20 default); |
|
1728 | + * @param int $current_page what is the current page being viewed. |
|
1729 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1730 | + * If FALSE then we return an array of event objects |
|
1731 | + * that match the given _view and paging parameters. |
|
1732 | + * @return array an array of event objects. |
|
1733 | + */ |
|
1734 | + public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1735 | + { |
|
1736 | + $EEME = $this->_event_model(); |
|
1737 | + $offset = ($current_page - 1) * $per_page; |
|
1738 | + $limit = $count ? null : $offset . ',' . $per_page; |
|
1739 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1740 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1741 | + if (isset($this->_req_data['month_range'])) { |
|
1742 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1743 | + //simulate the FIRST day of the month, that fixes issues for months like February |
|
1744 | + //where PHP doesn't know what to assume for date. |
|
1745 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10437 |
|
1746 | + $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; |
|
1747 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1748 | + } |
|
1749 | + $where = array(); |
|
1750 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1751 | + //determine what post_status our condition will have for the query. |
|
1752 | + switch ($status) { |
|
1753 | + case 'month' : |
|
1754 | + case 'today' : |
|
1755 | + case null : |
|
1756 | + case 'all' : |
|
1757 | + break; |
|
1758 | + case 'draft' : |
|
1759 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1760 | + break; |
|
1761 | + default : |
|
1762 | + $where['status'] = $status; |
|
1763 | + } |
|
1764 | + //categories? |
|
1765 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1766 | + ? $this->_req_data['EVT_CAT'] : null; |
|
1767 | + if ( ! empty ($category)) { |
|
1768 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1769 | + $where['Term_Taxonomy.term_id'] = $category; |
|
1770 | + } |
|
1771 | + //date where conditions |
|
1772 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1773 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1774 | + $DateTime = new DateTime( |
|
1775 | + $year_r . '-' . $month_r . '-01 00:00:00', |
|
1776 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1777 | + ); |
|
1778 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1779 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
1780 | + ->format('t'))->setTime(23, 59, 59) |
|
1781 | + ->format(implode(' ', $start_formats)); |
|
1782 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1783 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1784 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1785 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1786 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1787 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1788 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1789 | + $now = date('Y-m-01'); |
|
1790 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1791 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1792 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1793 | + ->setTime(23, 59, 59) |
|
1794 | + ->format(implode(' ', $start_formats)); |
|
1795 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1796 | + } |
|
1797 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1798 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1799 | + } else { |
|
1800 | + if ( ! isset($where['status'])) { |
|
1801 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1802 | + $where['OR'] = array( |
|
1803 | + 'status*restrict_private' => array('!=', 'private'), |
|
1804 | + 'AND' => array( |
|
1805 | + 'status*inclusive' => array('=', 'private'), |
|
1806 | + 'EVT_wp_user' => get_current_user_id(), |
|
1807 | + ), |
|
1808 | + ); |
|
1809 | + } |
|
1810 | + } |
|
1811 | + } |
|
1812 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1813 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1814 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1815 | + ) { |
|
1816 | + $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1817 | + } |
|
1818 | + } |
|
1819 | + //search query handling |
|
1820 | + if (isset($this->_req_data['s'])) { |
|
1821 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1822 | + $where['OR'] = array( |
|
1823 | + 'EVT_name' => array('LIKE', $search_string), |
|
1824 | + 'EVT_desc' => array('LIKE', $search_string), |
|
1825 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
1826 | + ); |
|
1827 | + } |
|
1828 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1829 | + $query_params = apply_filters( |
|
1830 | + 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1831 | + array( |
|
1832 | + $where, |
|
1833 | + 'limit' => $limit, |
|
1834 | + 'order_by' => $orderby, |
|
1835 | + 'order' => $order, |
|
1836 | + 'group_by' => 'EVT_ID', |
|
1837 | + ), |
|
1838 | + $this->_req_data |
|
1839 | + ); |
|
1840 | + //let's first check if we have special requests coming in. |
|
1841 | + if (isset($this->_req_data['active_status'])) { |
|
1842 | + switch ($this->_req_data['active_status']) { |
|
1843 | + case 'upcoming' : |
|
1844 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1845 | + break; |
|
1846 | + case 'expired' : |
|
1847 | + return $EEME->get_expired_events($query_params, $count); |
|
1848 | + break; |
|
1849 | + case 'active' : |
|
1850 | + return $EEME->get_active_events($query_params, $count); |
|
1851 | + break; |
|
1852 | + case 'inactive' : |
|
1853 | + return $EEME->get_inactive_events($query_params, $count); |
|
1854 | + break; |
|
1855 | + } |
|
1856 | + } |
|
1857 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1858 | + return $events; |
|
1859 | + } |
|
1860 | + |
|
1861 | + |
|
1862 | + |
|
1863 | + /** |
|
1864 | + * handling for WordPress CPT actions (trash, restore, delete) |
|
1865 | + * |
|
1866 | + * @param string $post_id |
|
1867 | + */ |
|
1868 | + public function trash_cpt_item($post_id) |
|
1869 | + { |
|
1870 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1871 | + $this->_trash_or_restore_event('trash', false); |
|
1872 | + } |
|
1873 | + |
|
1874 | + |
|
1875 | + |
|
1876 | + /** |
|
1877 | + * @param string $post_id |
|
1878 | + */ |
|
1879 | + public function restore_cpt_item($post_id) |
|
1880 | + { |
|
1881 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1882 | + $this->_trash_or_restore_event('draft', false); |
|
1883 | + } |
|
1884 | + |
|
1885 | + |
|
1886 | + |
|
1887 | + /** |
|
1888 | + * @param string $post_id |
|
1889 | + */ |
|
1890 | + public function delete_cpt_item($post_id) |
|
1891 | + { |
|
1892 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1893 | + $this->_delete_event(false); |
|
1894 | + } |
|
1895 | + |
|
1896 | + |
|
1897 | + |
|
1898 | + /** |
|
1899 | + * _trash_or_restore_event |
|
1900 | + * |
|
1901 | + * @access protected |
|
1902 | + * @param string $event_status |
|
1903 | + * @param bool $redirect_after |
|
1904 | + */ |
|
1905 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1906 | + { |
|
1907 | + //determine the event id and set to array. |
|
1908 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1909 | + // loop thru events |
|
1910 | + if ($EVT_ID) { |
|
1911 | + // clean status |
|
1912 | + $event_status = sanitize_key($event_status); |
|
1913 | + // grab status |
|
1914 | + if ( ! empty($event_status)) { |
|
1915 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1916 | + } else { |
|
1917 | + $success = false; |
|
1918 | + $msg = esc_html__( |
|
1919 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1920 | + 'event_espresso' |
|
1921 | + ); |
|
1922 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1923 | + } |
|
1924 | + } else { |
|
1925 | + $success = false; |
|
1926 | + $msg = esc_html__( |
|
1927 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1928 | + 'event_espresso' |
|
1929 | + ); |
|
1930 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1931 | + } |
|
1932 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1933 | + if ($redirect_after) { |
|
1934 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1935 | + } |
|
1936 | + } |
|
1937 | + |
|
1938 | + |
|
1939 | + |
|
1940 | + /** |
|
1941 | + * _trash_or_restore_events |
|
1942 | + * |
|
1943 | + * @access protected |
|
1944 | + * @param string $event_status |
|
1945 | + * @return void |
|
1946 | + */ |
|
1947 | + protected function _trash_or_restore_events($event_status = 'trash') |
|
1948 | + { |
|
1949 | + // clean status |
|
1950 | + $event_status = sanitize_key($event_status); |
|
1951 | + // grab status |
|
1952 | + if ( ! empty($event_status)) { |
|
1953 | + $success = true; |
|
1954 | + //determine the event id and set to array. |
|
1955 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1956 | + // loop thru events |
|
1957 | + foreach ($EVT_IDs as $EVT_ID) { |
|
1958 | + if ($EVT_ID = absint($EVT_ID)) { |
|
1959 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1960 | + $success = $results !== false ? $success : false; |
|
1961 | + } else { |
|
1962 | + $msg = sprintf( |
|
1963 | + esc_html__( |
|
1964 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1965 | + 'event_espresso' |
|
1966 | + ), |
|
1967 | + $EVT_ID |
|
1968 | + ); |
|
1969 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1970 | + $success = false; |
|
1971 | + } |
|
1972 | + } |
|
1973 | + } else { |
|
1974 | + $success = false; |
|
1975 | + $msg = esc_html__( |
|
1976 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1977 | + 'event_espresso' |
|
1978 | + ); |
|
1979 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1980 | + } |
|
1981 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1982 | + $success = $success ? 2 : false; |
|
1983 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1984 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1985 | + } |
|
1986 | + |
|
1987 | + |
|
1988 | + |
|
1989 | + /** |
|
1990 | + * _trash_or_restore_events |
|
1991 | + * |
|
1992 | + * @access private |
|
1993 | + * @param int $EVT_ID |
|
1994 | + * @param string $event_status |
|
1995 | + * @return bool |
|
1996 | + */ |
|
1997 | + private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1998 | + { |
|
1999 | + // grab event id |
|
2000 | + if ( ! $EVT_ID) { |
|
2001 | + $msg = esc_html__( |
|
2002 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2003 | + 'event_espresso' |
|
2004 | + ); |
|
2005 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2006 | + return false; |
|
2007 | + } |
|
2008 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2009 | + // clean status |
|
2010 | + $event_status = sanitize_key($event_status); |
|
2011 | + // grab status |
|
2012 | + if (empty($event_status)) { |
|
2013 | + $msg = esc_html__( |
|
2014 | + 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
2015 | + 'event_espresso' |
|
2016 | + ); |
|
2017 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2018 | + return false; |
|
2019 | + } |
|
2020 | + // was event trashed or restored ? |
|
2021 | + switch ($event_status) { |
|
2022 | + case 'draft' : |
|
2023 | + $action = 'restored from the trash'; |
|
2024 | + $hook = 'AHEE_event_restored_from_trash'; |
|
2025 | + break; |
|
2026 | + case 'trash' : |
|
2027 | + $action = 'moved to the trash'; |
|
2028 | + $hook = 'AHEE_event_moved_to_trash'; |
|
2029 | + break; |
|
2030 | + default : |
|
2031 | + $action = 'updated'; |
|
2032 | + $hook = false; |
|
2033 | + } |
|
2034 | + //use class to change status |
|
2035 | + $this->_cpt_model_obj->set_status($event_status); |
|
2036 | + $success = $this->_cpt_model_obj->save(); |
|
2037 | + if ($success === false) { |
|
2038 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2039 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2040 | + return false; |
|
2041 | + } |
|
2042 | + if ($hook) { |
|
2043 | + do_action($hook); |
|
2044 | + } |
|
2045 | + return true; |
|
2046 | + } |
|
2047 | + |
|
2048 | + |
|
2049 | + |
|
2050 | + /** |
|
2051 | + * _delete_event |
|
2052 | + * |
|
2053 | + * @access protected |
|
2054 | + * @param bool $redirect_after |
|
2055 | + */ |
|
2056 | + protected function _delete_event($redirect_after = true) |
|
2057 | + { |
|
2058 | + //determine the event id and set to array. |
|
2059 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2060 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2061 | + // loop thru events |
|
2062 | + if ($EVT_ID) { |
|
2063 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
2064 | + // get list of events with no prices |
|
2065 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2066 | + // remove this event from the list of events with no prices |
|
2067 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2068 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2069 | + } |
|
2070 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2071 | + } else { |
|
2072 | + $success = false; |
|
2073 | + $msg = esc_html__( |
|
2074 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2075 | + 'event_espresso' |
|
2076 | + ); |
|
2077 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2078 | + } |
|
2079 | + if ($redirect_after) { |
|
2080 | + $this->_redirect_after_action( |
|
2081 | + $success, |
|
2082 | + 'Event', |
|
2083 | + 'deleted', |
|
2084 | + array('action' => 'default', 'status' => 'trash') |
|
2085 | + ); |
|
2086 | + } |
|
2087 | + } |
|
2088 | + |
|
2089 | + |
|
2090 | + |
|
2091 | + /** |
|
2092 | + * _delete_events |
|
2093 | + * |
|
2094 | + * @access protected |
|
2095 | + * @return void |
|
2096 | + */ |
|
2097 | + protected function _delete_events() |
|
2098 | + { |
|
2099 | + $success = true; |
|
2100 | + // get list of events with no prices |
|
2101 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2102 | + //determine the event id and set to array. |
|
2103 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2104 | + // loop thru events |
|
2105 | + foreach ($EVT_IDs as $EVT_ID) { |
|
2106 | + $EVT_ID = absint($EVT_ID); |
|
2107 | + if ($EVT_ID) { |
|
2108 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
2109 | + $success = $results !== false ? $success : false; |
|
2110 | + // remove this event from the list of events with no prices |
|
2111 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2112 | + } else { |
|
2113 | + $success = false; |
|
2114 | + $msg = esc_html__( |
|
2115 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2116 | + 'event_espresso' |
|
2117 | + ); |
|
2118 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2119 | + } |
|
2120 | + } |
|
2121 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2122 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2123 | + $success = $success ? 2 : false; |
|
2124 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2125 | + } |
|
2126 | + |
|
2127 | + |
|
2128 | + |
|
2129 | + /** |
|
2130 | + * _permanently_delete_event |
|
2131 | + * |
|
2132 | + * @access private |
|
2133 | + * @param int $EVT_ID |
|
2134 | + * @return bool |
|
2135 | + */ |
|
2136 | + private function _permanently_delete_event($EVT_ID = 0) |
|
2137 | + { |
|
2138 | + // grab event id |
|
2139 | + if ( ! $EVT_ID) { |
|
2140 | + $msg = esc_html__( |
|
2141 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2142 | + 'event_espresso' |
|
2143 | + ); |
|
2144 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2145 | + return false; |
|
2146 | + } |
|
2147 | + if ( |
|
2148 | + ! $this->_cpt_model_obj instanceof EE_Event |
|
2149 | + || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2150 | + ) { |
|
2151 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2152 | + } |
|
2153 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2154 | + return false; |
|
2155 | + } |
|
2156 | + //need to delete related tickets and prices first. |
|
2157 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2158 | + foreach ($datetimes as $datetime) { |
|
2159 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2160 | + $tickets = $datetime->get_many_related('Ticket'); |
|
2161 | + foreach ($tickets as $ticket) { |
|
2162 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2163 | + $ticket->delete_related_permanently('Price'); |
|
2164 | + $ticket->delete_permanently(); |
|
2165 | + } |
|
2166 | + $datetime->delete(); |
|
2167 | + } |
|
2168 | + //what about related venues or terms? |
|
2169 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2170 | + foreach ($venues as $venue) { |
|
2171 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2172 | + } |
|
2173 | + //any attached question groups? |
|
2174 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2175 | + if ( ! empty($question_groups)) { |
|
2176 | + foreach ($question_groups as $question_group) { |
|
2177 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2178 | + } |
|
2179 | + } |
|
2180 | + //Message Template Groups |
|
2181 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2182 | + /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2183 | + $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2184 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
2185 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2186 | + } |
|
2187 | + $success = $this->_cpt_model_obj->delete_permanently(); |
|
2188 | + // did it all go as planned ? |
|
2189 | + if ($success) { |
|
2190 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2191 | + EE_Error::add_success($msg); |
|
2192 | + } else { |
|
2193 | + $msg = sprintf( |
|
2194 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2195 | + $EVT_ID |
|
2196 | + ); |
|
2197 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2198 | + return false; |
|
2199 | + } |
|
2200 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2201 | + return true; |
|
2202 | + } |
|
2203 | + |
|
2204 | + |
|
2205 | + |
|
2206 | + /** |
|
2207 | + * get total number of events |
|
2208 | + * |
|
2209 | + * @access public |
|
2210 | + * @return int |
|
2211 | + */ |
|
2212 | + public function total_events() |
|
2213 | + { |
|
2214 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2215 | + return $count; |
|
2216 | + } |
|
2217 | + |
|
2218 | + |
|
2219 | + |
|
2220 | + /** |
|
2221 | + * get total number of draft events |
|
2222 | + * |
|
2223 | + * @access public |
|
2224 | + * @return int |
|
2225 | + */ |
|
2226 | + public function total_events_draft() |
|
2227 | + { |
|
2228 | + $where = array( |
|
2229 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
2230 | + ); |
|
2231 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2232 | + return $count; |
|
2233 | + } |
|
2234 | + |
|
2235 | + |
|
2236 | + |
|
2237 | + /** |
|
2238 | + * get total number of trashed events |
|
2239 | + * |
|
2240 | + * @access public |
|
2241 | + * @return int |
|
2242 | + */ |
|
2243 | + public function total_trashed_events() |
|
2244 | + { |
|
2245 | + $where = array( |
|
2246 | + 'status' => 'trash', |
|
2247 | + ); |
|
2248 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2249 | + return $count; |
|
2250 | + } |
|
2251 | + |
|
2252 | + |
|
2253 | + |
|
2254 | + /** |
|
2255 | + * _default_event_settings |
|
2256 | + * This generates the Default Settings Tab |
|
2257 | + * |
|
2258 | + * @return void |
|
2259 | + */ |
|
2260 | + protected function _default_event_settings() |
|
2261 | + { |
|
2262 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
2263 | + $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2264 | + // exclude array |
|
2265 | + array( |
|
2266 | + EEM_Registration::status_id_cancelled, |
|
2267 | + EEM_Registration::status_id_declined, |
|
2268 | + EEM_Registration::status_id_incomplete, |
|
2269 | + EEM_Registration::status_id_wait_list, |
|
2270 | + ), |
|
2271 | + // translated |
|
2272 | + true |
|
2273 | + ); |
|
2274 | + $this->_template_args['default_reg_status'] = isset( |
|
2275 | + EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2276 | + ) |
|
2277 | + && array_key_exists( |
|
2278 | + EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2279 | + $this->_template_args['reg_status_array'] |
|
2280 | + ) |
|
2281 | + ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2282 | + : EEM_Registration::status_id_pending_payment; |
|
2283 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2284 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2285 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2286 | + EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2287 | + $this->_template_args, |
|
2288 | + true |
|
2289 | + ); |
|
2290 | + $this->display_admin_page_with_sidebar(); |
|
2291 | + } |
|
2292 | + |
|
2293 | + |
|
2294 | + |
|
2295 | + /** |
|
2296 | + * _update_default_event_settings |
|
2297 | + * |
|
2298 | + * @access protected |
|
2299 | + * @return void |
|
2300 | + */ |
|
2301 | + protected function _update_default_event_settings() |
|
2302 | + { |
|
2303 | + EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2304 | + ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2305 | + : EEM_Registration::status_id_pending_payment; |
|
2306 | + $what = 'Default Event Settings'; |
|
2307 | + $success = $this->_update_espresso_configuration( |
|
2308 | + $what, |
|
2309 | + EE_Config::instance(), |
|
2310 | + __FILE__, |
|
2311 | + __FUNCTION__, |
|
2312 | + __LINE__ |
|
2313 | + ); |
|
2314 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2315 | + } |
|
2316 | + |
|
2317 | + |
|
2318 | + |
|
2319 | + /************* Templates *************/ |
|
2320 | + protected function _template_settings() |
|
2321 | + { |
|
2322 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2323 | + $this->_template_args['preview_img'] = '<img src="' |
|
2324 | + . EVENTS_ASSETS_URL |
|
2325 | + . DS |
|
2326 | + . 'images' |
|
2327 | + . DS |
|
2328 | + . 'caffeinated_template_features.jpg" alt="' |
|
2329 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2330 | + . '" />'; |
|
2331 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2332 | + 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
2333 | + 'event_espresso' |
|
2334 | + ) . '</strong>'; |
|
2335 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2336 | + } |
|
2337 | + |
|
2338 | + |
|
2339 | + /** Event Category Stuff **/ |
|
2340 | + /** |
|
2341 | + * set the _category property with the category object for the loaded page. |
|
2342 | + * |
|
2343 | + * @access private |
|
2344 | + * @return void |
|
2345 | + */ |
|
2346 | + private function _set_category_object() |
|
2347 | + { |
|
2348 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2349 | + return; |
|
2350 | + } //already have the category object so get out. |
|
2351 | + //set default category object |
|
2352 | + $this->_set_empty_category_object(); |
|
2353 | + //only set if we've got an id |
|
2354 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2355 | + return; |
|
2356 | + } |
|
2357 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2358 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2359 | + if ( ! empty($term)) { |
|
2360 | + $this->_category->category_name = $term->name; |
|
2361 | + $this->_category->category_identifier = $term->slug; |
|
2362 | + $this->_category->category_desc = $term->description; |
|
2363 | + $this->_category->id = $term->term_id; |
|
2364 | + $this->_category->parent = $term->parent; |
|
2365 | + } |
|
2366 | + } |
|
2367 | + |
|
2368 | + |
|
2369 | + |
|
2370 | + private function _set_empty_category_object() |
|
2371 | + { |
|
2372 | + $this->_category = new stdClass(); |
|
2373 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2374 | + $this->_category->id = $this->_category->parent = 0; |
|
2375 | + } |
|
2376 | + |
|
2377 | + |
|
2378 | + |
|
2379 | + protected function _category_list_table() |
|
2380 | + { |
|
2381 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2382 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2383 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2384 | + 'add_category', |
|
2385 | + 'add_category', |
|
2386 | + array(), |
|
2387 | + 'add-new-h2' |
|
2388 | + ); |
|
2389 | + $this->display_admin_list_table_page_with_sidebar(); |
|
2390 | + } |
|
2391 | + |
|
2392 | + |
|
2393 | + |
|
2394 | + /** |
|
2395 | + * @param $view |
|
2396 | + */ |
|
2397 | + protected function _category_details($view) |
|
2398 | + { |
|
2399 | + //load formatter helper |
|
2400 | + //load field generator helper |
|
2401 | + $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2402 | + $this->_set_add_edit_form_tags($route); |
|
2403 | + $this->_set_category_object(); |
|
2404 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2405 | + $delete_action = 'delete_category'; |
|
2406 | + //custom redirect |
|
2407 | + $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2408 | + array('action' => 'category_list'), |
|
2409 | + $this->_admin_base_url |
|
2410 | + ); |
|
2411 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2412 | + //take care of contents |
|
2413 | + $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2414 | + $this->display_admin_page_with_sidebar(); |
|
2415 | + } |
|
2416 | + |
|
2417 | + |
|
2418 | + |
|
2419 | + /** |
|
2420 | + * @return mixed |
|
2421 | + */ |
|
2422 | + protected function _category_details_content() |
|
2423 | + { |
|
2424 | + $editor_args['category_desc'] = array( |
|
2425 | + 'type' => 'wp_editor', |
|
2426 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2427 | + 'class' => 'my_editor_custom', |
|
2428 | + 'wpeditor_args' => array('media_buttons' => false), |
|
2429 | + ); |
|
2430 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2431 | + $all_terms = get_terms( |
|
2432 | + array('espresso_event_categories'), |
|
2433 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2434 | + ); |
|
2435 | + //setup category select for term parents. |
|
2436 | + $category_select_values[] = array( |
|
2437 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2438 | + 'id' => 0, |
|
2439 | + ); |
|
2440 | + foreach ($all_terms as $term) { |
|
2441 | + $category_select_values[] = array( |
|
2442 | + 'text' => $term->name, |
|
2443 | + 'id' => $term->term_id, |
|
2444 | + ); |
|
2445 | + } |
|
2446 | + $category_select = EEH_Form_Fields::select_input( |
|
2447 | + 'category_parent', |
|
2448 | + $category_select_values, |
|
2449 | + $this->_category->parent |
|
2450 | + ); |
|
2451 | + $template_args = array( |
|
2452 | + 'category' => $this->_category, |
|
2453 | + 'category_select' => $category_select, |
|
2454 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2455 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2456 | + 'disable' => '', |
|
2457 | + 'disabled_message' => false, |
|
2458 | + ); |
|
2459 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2460 | + return EEH_Template::display_template($template, $template_args, true); |
|
2461 | + } |
|
2462 | + |
|
2463 | + |
|
2464 | + |
|
2465 | + protected function _delete_categories() |
|
2466 | + { |
|
2467 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2468 | + : (array)$this->_req_data['category_id']; |
|
2469 | + foreach ($cat_ids as $cat_id) { |
|
2470 | + $this->_delete_category($cat_id); |
|
2471 | + } |
|
2472 | + //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2473 | + $query_args = array( |
|
2474 | + 'action' => 'category_list', |
|
2475 | + ); |
|
2476 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2477 | + } |
|
2478 | + |
|
2479 | + |
|
2480 | + |
|
2481 | + /** |
|
2482 | + * @param $cat_id |
|
2483 | + */ |
|
2484 | + protected function _delete_category($cat_id) |
|
2485 | + { |
|
2486 | + $cat_id = absint($cat_id); |
|
2487 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2488 | + } |
|
2489 | + |
|
2490 | + |
|
2491 | + |
|
2492 | + /** |
|
2493 | + * @param $new_category |
|
2494 | + */ |
|
2495 | + protected function _insert_or_update_category($new_category) |
|
2496 | + { |
|
2497 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2498 | + $success = 0; //we already have a success message so lets not send another. |
|
2499 | + if ($cat_id) { |
|
2500 | + $query_args = array( |
|
2501 | + 'action' => 'edit_category', |
|
2502 | + 'EVT_CAT_ID' => $cat_id, |
|
2503 | + ); |
|
2504 | + } else { |
|
2505 | + $query_args = array('action' => 'add_category'); |
|
2506 | + } |
|
2507 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2508 | + } |
|
2509 | + |
|
2510 | + |
|
2511 | + |
|
2512 | + /** |
|
2513 | + * @param bool $update |
|
2514 | + * @return bool|mixed|string |
|
2515 | + */ |
|
2516 | + private function _insert_category($update = false) |
|
2517 | + { |
|
2518 | + $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2519 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2520 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2521 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2522 | + if (empty($category_name)) { |
|
2523 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2524 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2525 | + return false; |
|
2526 | + } |
|
2527 | + $term_args = array( |
|
2528 | + 'name' => $category_name, |
|
2529 | + 'description' => $category_desc, |
|
2530 | + 'parent' => $category_parent, |
|
2531 | + ); |
|
2532 | + //was the category_identifier input disabled? |
|
2533 | + if (isset($this->_req_data['category_identifier'])) { |
|
2534 | + $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2535 | + } |
|
2536 | + $insert_ids = $update |
|
2537 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2538 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2539 | + if ( ! is_array($insert_ids)) { |
|
2540 | + $msg = esc_html__( |
|
2541 | + 'An error occurred and the category has not been saved to the database.', |
|
2542 | + 'event_espresso' |
|
2543 | + ); |
|
2544 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2545 | + } else { |
|
2546 | + $cat_id = $insert_ids['term_id']; |
|
2547 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2548 | + EE_Error::add_success($msg); |
|
2549 | + } |
|
2550 | + return $cat_id; |
|
2551 | + } |
|
2552 | + |
|
2553 | + |
|
2554 | + |
|
2555 | + /** |
|
2556 | + * @param int $per_page |
|
2557 | + * @param int $current_page |
|
2558 | + * @param bool $count |
|
2559 | + * @return \EE_Base_Class[]|int |
|
2560 | + */ |
|
2561 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2562 | + { |
|
2563 | + //testing term stuff |
|
2564 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2565 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2566 | + $limit = ($current_page - 1) * $per_page; |
|
2567 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2568 | + if (isset($this->_req_data['s'])) { |
|
2569 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2570 | + $where['OR'] = array( |
|
2571 | + 'Term.name' => array('LIKE', $sstr), |
|
2572 | + 'description' => array('LIKE', $sstr), |
|
2573 | + ); |
|
2574 | + } |
|
2575 | + $query_params = array( |
|
2576 | + $where, |
|
2577 | + 'order_by' => array($orderby => $order), |
|
2578 | + 'limit' => $limit . ',' . $per_page, |
|
2579 | + 'force_join' => array('Term'), |
|
2580 | + ); |
|
2581 | + $categories = $count |
|
2582 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2583 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2584 | + return $categories; |
|
2585 | + } |
|
2586 | + |
|
2587 | + |
|
2588 | + |
|
2589 | + /* end category stuff */ |
|
2590 | + /**************/ |
|
2591 | 2591 | } |
2592 | 2592 | //end class Events_Admin_Page |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | *@param array $settings_array |
98 | 98 | */ |
99 | - public function set_settings( $settings_array ) { |
|
99 | + public function set_settings($settings_array) { |
|
100 | 100 | parent::set_settings($settings_array); |
101 | 101 | // Redirect URL. |
102 | 102 | $this->_base_gateway_url = $this->_debug_mode |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | * @return \EE_Payment|\EEI_Payment |
116 | 116 | * @throws \EE_Error |
117 | 117 | */ |
118 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
119 | - if ( ! $payment instanceof EEI_Payment ) { |
|
120 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
121 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
118 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
119 | + if ( ! $payment instanceof EEI_Payment) { |
|
120 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
121 | + $payment->set_status($this->_pay_model->failed_status()); |
|
122 | 122 | return $payment; |
123 | 123 | } |
124 | 124 | $transaction = $payment->transaction(); |
125 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
126 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
127 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
125 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
126 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
127 | + $payment->set_status($this->_pay_model->failed_status()); |
|
128 | 128 | return $payment; |
129 | 129 | } |
130 | - $order_description = substr( $this->_format_order_description($payment), 0, 127 ); |
|
130 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
131 | 131 | $primary_registration = $transaction->primary_registration(); |
132 | 132 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
133 | 133 | $locale = explode('-', get_bloginfo('language')); |
@@ -141,37 +141,37 @@ discard block |
||
141 | 141 | 'RETURNURL' => $return_url, |
142 | 142 | 'CANCELURL' => $cancel_url, |
143 | 143 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
144 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
144 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
146 | 146 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
147 | 147 | ); |
148 | 148 | |
149 | 149 | // Show itemized list. |
150 | - if ( $this->_money->compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
150 | + if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
151 | 151 | $item_num = 0; |
152 | 152 | $itemized_sum = 0; |
153 | 153 | $total_line_items = $transaction->total_line_item(); |
154 | 154 | // Go through each item in the list. |
155 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
156 | - if ( $line_item instanceof EE_Line_Item ) { |
|
155 | + foreach ($total_line_items->get_items() as $line_item) { |
|
156 | + if ($line_item instanceof EE_Line_Item) { |
|
157 | 157 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
158 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
158 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
162 | 162 | $unit_price = $line_item->unit_price(); |
163 | 163 | $line_item_quantity = $line_item->quantity(); |
164 | 164 | // This is a discount. |
165 | - if ( $line_item->is_percent() ) { |
|
165 | + if ($line_item->is_percent()) { |
|
166 | 166 | $unit_price = $line_item->total(); |
167 | 167 | $line_item_quantity = 1; |
168 | 168 | } |
169 | 169 | // Item Name. |
170 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name( $line_item, $payment), 0, 127); |
|
170 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name($line_item, $payment), 0, 127); |
|
171 | 171 | // Item description. |
172 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc( $line_item, $payment), 0, 127); |
|
172 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc($line_item, $payment), 0, 127); |
|
173 | 173 | // Cost of individual item. |
174 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
174 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
175 | 175 | // Item Number. |
176 | 176 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
177 | 177 | // Item quantity. |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
189 | 189 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
190 | 190 | |
191 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
191 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
192 | 192 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
193 | 193 | // add the difference as an extra line item. |
194 | - if ( $this->_money->compare_floats( $itemized_sum_diff_from_txn_total, 0, '!=' ) ) { |
|
194 | + if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
195 | 195 | // Item Name. |
196 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
196 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
197 | 197 | // Item description. |
198 | 198 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = ''; |
199 | 199 | // Cost of individual item. |
200 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
200 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
201 | 201 | // Item Number. |
202 | 202 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
203 | 203 | // Item quantity. |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | } else { |
210 | 210 | // Just one Item. |
211 | 211 | // Item Name. |
212 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( $this->_format_partial_payment_line_item_name($payment), 0, 127 ); |
|
212 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr($this->_format_partial_payment_line_item_name($payment), 0, 127); |
|
213 | 213 | // Item description. |
214 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( $this->_format_partial_payment_line_item_desc($payment), 0, 127 ); |
|
214 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr($this->_format_partial_payment_line_item_desc($payment), 0, 127); |
|
215 | 215 | // Cost of individual item. |
216 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
216 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
217 | 217 | // Item Number. |
218 | 218 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
219 | 219 | // Item quantity. |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | // Digital item is sold. |
222 | 222 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
223 | 223 | // Item's sales S/H and tax amount. |
224 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
224 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
225 | 225 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
226 | 226 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
227 | 227 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
228 | 228 | } |
229 | 229 | // Automatically filling out shipping and contact information. |
230 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
231 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
230 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
231 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
232 | 232 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
233 | 233 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
234 | 234 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
238 | 238 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
239 | 239 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
240 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
240 | + } elseif ( ! $this->_request_shipping_addr) { |
|
241 | 241 | // Do not request shipping details on the PP Checkout page. |
242 | 242 | $token_request_dtls['NOSHIPPING'] = '1'; |
243 | 243 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
244 | 244 | |
245 | 245 | } |
246 | 246 | // Used a business/personal logo on the PayPal page. |
247 | - if ( ! empty($this->_image_url) ) { |
|
247 | + if ( ! empty($this->_image_url)) { |
|
248 | 248 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
249 | 249 | } |
250 | 250 | $token_request_dtls = apply_filters( |
@@ -253,23 +253,23 @@ discard block |
||
253 | 253 | $this |
254 | 254 | ); |
255 | 255 | // Request PayPal token. |
256 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
257 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
258 | - $response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
259 | - if ( $token_rstatus['status'] ) { |
|
256 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
257 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
258 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
259 | + if ($token_rstatus['status']) { |
|
260 | 260 | // We got the Token so we may continue with the payment and redirect the client. |
261 | - $payment->set_details( $response_args ); |
|
261 | + $payment->set_details($response_args); |
|
262 | 262 | |
263 | 263 | $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
264 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
264 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
265 | 265 | } else { |
266 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
267 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
266 | + if (isset($response_args['L_ERRORCODE'])) { |
|
267 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
268 | 268 | } else { |
269 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
269 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
270 | 270 | } |
271 | - $payment->set_details( $response_args ); |
|
272 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
271 | + $payment->set_details($response_args); |
|
272 | + $payment->set_status($this->_pay_model->failed_status()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $payment; |
@@ -285,22 +285,22 @@ discard block |
||
285 | 285 | * @param EEI_Transaction $transaction |
286 | 286 | * @return EEI_Payment |
287 | 287 | */ |
288 | - public function handle_payment_update( $update_info, $transaction ) { |
|
288 | + public function handle_payment_update($update_info, $transaction) { |
|
289 | 289 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
290 | 290 | |
291 | - if ( $payment instanceof EEI_Payment ) { |
|
292 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
291 | + if ($payment instanceof EEI_Payment) { |
|
292 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
293 | 293 | $transaction = $payment->transaction(); |
294 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
295 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
296 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
294 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
295 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
296 | + $payment->set_status($this->_pay_model->failed_status()); |
|
297 | 297 | return $payment; |
298 | 298 | } |
299 | 299 | $primary_registrant = $transaction->primary_registration(); |
300 | 300 | $payment_details = $payment->details(); |
301 | 301 | // Check if we still have the token. |
302 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
303 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
302 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
303 | + $payment->set_status($this->_pay_model->failed_status()); |
|
304 | 304 | return $payment; |
305 | 305 | } |
306 | 306 | |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | 'TOKEN' => $payment_details['TOKEN'] |
310 | 310 | ); |
311 | 311 | // Request Customer Details. |
312 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
313 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
314 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
315 | - if ( $cdetails_rstatus['status'] ) { |
|
312 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
313 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
314 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
315 | + if ($cdetails_rstatus['status']) { |
|
316 | 316 | // We got the PayerID so now we can Complete the transaction. |
317 | 317 | $docheckout_request_dtls = array( |
318 | 318 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -323,39 +323,39 @@ discard block |
||
323 | 323 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
324 | 324 | ); |
325 | 325 | // Payment Checkout/Capture. |
326 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
327 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
328 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
329 | - if ( $docheckout_rstatus['status'] ) { |
|
326 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
327 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
328 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
329 | + if ($docheckout_rstatus['status']) { |
|
330 | 330 | // All is well, payment approved. |
331 | 331 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
332 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
333 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0 ); |
|
334 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
335 | - $payment->set_details( $cdata_response_args ); |
|
336 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
337 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
332 | + $payment->set_extra_accntng($primary_registration_code); |
|
333 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0); |
|
334 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
335 | + $payment->set_details($cdata_response_args); |
|
336 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
337 | + $payment->set_status($this->_pay_model->approved_status()); |
|
338 | 338 | } else { |
339 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
340 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
339 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
340 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
341 | 341 | } else { |
342 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
342 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
343 | 343 | } |
344 | - $payment->set_details( $docheckout_response_args ); |
|
345 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
344 | + $payment->set_details($docheckout_response_args); |
|
345 | + $payment->set_status($this->_pay_model->declined_status()); |
|
346 | 346 | } |
347 | 347 | } else { |
348 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
349 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
348 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
349 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
350 | 350 | } else { |
351 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
351 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
352 | 352 | } |
353 | - $payment->set_details( $cdata_response_args ); |
|
354 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
353 | + $payment->set_details($cdata_response_args); |
|
354 | + $payment->set_status($this->_pay_model->failed_status()); |
|
355 | 355 | } |
356 | 356 | } else { |
357 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
358 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
357 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
358 | + $payment->set_status($this->_pay_model->failed_status()); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | return $payment; |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * @param EEI_Payment $payment |
371 | 371 | * @return mixed |
372 | 372 | */ |
373 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
373 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
374 | 374 | $request_dtls = array( |
375 | 375 | 'VERSION' => '204.0', |
376 | - 'USER' => urlencode( $this->_api_username ), |
|
377 | - 'PWD' => urlencode( $this->_api_password ), |
|
378 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
376 | + 'USER' => urlencode($this->_api_username), |
|
377 | + 'PWD' => urlencode($this->_api_password), |
|
378 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
379 | 379 | ); |
380 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
380 | + $dtls = array_merge($request_dtls, $request_params); |
|
381 | 381 | |
382 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
382 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
383 | 383 | // Request Customer Details. |
384 | 384 | $request_response = wp_remote_post( |
385 | 385 | $this->_base_gateway_url, |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | 'httpversion' => '1.1', |
390 | 390 | 'cookies' => array(), |
391 | 391 | 'headers' => array(), |
392 | - 'body' => http_build_query( $dtls ) |
|
392 | + 'body' => http_build_query($dtls) |
|
393 | 393 | ) |
394 | 394 | ); |
395 | 395 | // Log the response. |
396 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
396 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
397 | 397 | |
398 | 398 | return $request_response; |
399 | 399 | } |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | * @param mixed $request_response |
406 | 406 | * @return array |
407 | 407 | */ |
408 | - public function _ppExpress_check_response( $request_response ) { |
|
409 | - if (empty($request_response['body']) || is_wp_error( $request_response ) ) { |
|
408 | + public function _ppExpress_check_response($request_response) { |
|
409 | + if (empty($request_response['body']) || is_wp_error($request_response)) { |
|
410 | 410 | // If we got here then there was an error in this request. |
411 | 411 | return array('status' => false, 'args' => $request_response); |
412 | 412 | } |
413 | 413 | $response_args = array(); |
414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
414 | + parse_str(urldecode($request_response['body']), $response_args); |
|
415 | 415 | if ( ! isset($response_args['ACK'])) { |
416 | 416 | return array('status' => false, 'args' => $request_response); |
417 | 417 | } |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | * @param string $info |
442 | 442 | * @return void |
443 | 443 | */ |
444 | - private function _log_clean_request($request, $payment, $info ) { |
|
444 | + private function _log_clean_request($request, $payment, $info) { |
|
445 | 445 | $cleaned_request_data = $request; |
446 | 446 | unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
447 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
447 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | * @param array $data_array |
455 | 455 | * @return array |
456 | 456 | */ |
457 | - private function _get_errors( $data_array ) { |
|
457 | + private function _get_errors($data_array) { |
|
458 | 458 | $errors = array(); |
459 | 459 | $n = 0; |
460 | - while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
|
460 | + while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
461 | 461 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
462 | 462 | ? $data_array["L_ERRORCODE{$n}"] |
463 | 463 | : ''; |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | ? $data_array["L_LONGMESSAGE{$n}"] |
472 | 472 | : ''; |
473 | 473 | |
474 | - if ( $n === 0 ) { |
|
474 | + if ($n === 0) { |
|
475 | 475 | $errors = array( |
476 | 476 | 'L_ERRORCODE' => $l_error_code, |
477 | 477 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | 'L_SEVERITYCODE' => $l_severity_code |
480 | 480 | ); |
481 | 481 | } else { |
482 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
483 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
484 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
485 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
482 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
483 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
484 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
485 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | $n++; |
@@ -16,222 +16,222 @@ |
||
16 | 16 | class Registry |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - protected $jsdata = array(); |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * Registry constructor. |
|
28 | - * Hooking into WP actions for script registry. |
|
29 | - */ |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - add_action('wp_enqueue_scripts', array($this, 'scripts'), 100); |
|
33 | - add_action('admin_enqueue_scripts', array($this, 'scripts'), 100); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * Callback for the WP script actions. |
|
39 | - * Used to register globally accessible core scripts. |
|
40 | - * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
41 | - */ |
|
42 | - public function scripts() |
|
43 | - { |
|
44 | - global $wp_version; |
|
45 | - wp_register_script( |
|
46 | - 'eejs-core', |
|
47 | - EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
48 | - array(), |
|
49 | - espresso_version(), |
|
50 | - true |
|
51 | - ); |
|
52 | - //only run this if WordPress 4.4.0 > is in use. |
|
53 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
54 | - //js.api |
|
55 | - wp_register_script( |
|
56 | - 'eejs-api', |
|
57 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
58 | - array('underscore', 'eejs-core'), |
|
59 | - espresso_version(), |
|
60 | - true |
|
61 | - ); |
|
62 | - $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
63 | - |
|
64 | - wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
65 | - } |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Used to add data to eejs.data object. |
|
71 | - * |
|
72 | - * Note: Overriding existing data is not allowed. |
|
73 | - * |
|
74 | - * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
75 | - * If the data you add is something like this: |
|
76 | - * |
|
77 | - * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
78 | - * |
|
79 | - * It will be exposed in the page source as: |
|
80 | - * |
|
81 | - * eejs.data.my_plugin_data.foo == gar |
|
82 | - * |
|
83 | - * @param string $key Key used to access your data |
|
84 | - * @param string|array $value Value to attach to key |
|
85 | - * @throws InvalidArgumentException |
|
86 | - */ |
|
87 | - public function addData($key, $value) |
|
88 | - { |
|
89 | - if ($this->verifyDataNotExisting($key)) { |
|
90 | - $this->jsdata[$key] = $value; |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
97 | - * elements in an array. |
|
98 | - * |
|
99 | - * When you use this method, the value you include will be appended to the end of an array on $key. |
|
100 | - * |
|
101 | - * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript object |
|
102 | - * like this, |
|
103 | - * |
|
104 | - * eejs.data.test = [ |
|
105 | - * my_data, |
|
106 | - * ] |
|
107 | - * |
|
108 | - * If there has already been a scalar value attached to the data object given key, then |
|
109 | - * this will throw an exception. |
|
110 | - * |
|
111 | - * @param string $key Key to attach data to. |
|
112 | - * @param string|array $value Value being registered. |
|
113 | - * @throws InvalidArgumentException |
|
114 | - */ |
|
115 | - public function pushData($key, $value) |
|
116 | - { |
|
117 | - if (isset($this->jsdata[$key]) |
|
118 | - && ! is_array($this->jsdata[$key]) |
|
119 | - ) { |
|
120 | - throw new invalidArgumentException( |
|
121 | - sprintf( |
|
122 | - __( |
|
123 | - 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
19 | + /** |
|
20 | + * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + protected $jsdata = array(); |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * Registry constructor. |
|
28 | + * Hooking into WP actions for script registry. |
|
29 | + */ |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + add_action('wp_enqueue_scripts', array($this, 'scripts'), 100); |
|
33 | + add_action('admin_enqueue_scripts', array($this, 'scripts'), 100); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * Callback for the WP script actions. |
|
39 | + * Used to register globally accessible core scripts. |
|
40 | + * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
41 | + */ |
|
42 | + public function scripts() |
|
43 | + { |
|
44 | + global $wp_version; |
|
45 | + wp_register_script( |
|
46 | + 'eejs-core', |
|
47 | + EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
48 | + array(), |
|
49 | + espresso_version(), |
|
50 | + true |
|
51 | + ); |
|
52 | + //only run this if WordPress 4.4.0 > is in use. |
|
53 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
54 | + //js.api |
|
55 | + wp_register_script( |
|
56 | + 'eejs-api', |
|
57 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
58 | + array('underscore', 'eejs-core'), |
|
59 | + espresso_version(), |
|
60 | + true |
|
61 | + ); |
|
62 | + $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
63 | + |
|
64 | + wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
65 | + } |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Used to add data to eejs.data object. |
|
71 | + * |
|
72 | + * Note: Overriding existing data is not allowed. |
|
73 | + * |
|
74 | + * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
75 | + * If the data you add is something like this: |
|
76 | + * |
|
77 | + * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
78 | + * |
|
79 | + * It will be exposed in the page source as: |
|
80 | + * |
|
81 | + * eejs.data.my_plugin_data.foo == gar |
|
82 | + * |
|
83 | + * @param string $key Key used to access your data |
|
84 | + * @param string|array $value Value to attach to key |
|
85 | + * @throws InvalidArgumentException |
|
86 | + */ |
|
87 | + public function addData($key, $value) |
|
88 | + { |
|
89 | + if ($this->verifyDataNotExisting($key)) { |
|
90 | + $this->jsdata[$key] = $value; |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
97 | + * elements in an array. |
|
98 | + * |
|
99 | + * When you use this method, the value you include will be appended to the end of an array on $key. |
|
100 | + * |
|
101 | + * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript object |
|
102 | + * like this, |
|
103 | + * |
|
104 | + * eejs.data.test = [ |
|
105 | + * my_data, |
|
106 | + * ] |
|
107 | + * |
|
108 | + * If there has already been a scalar value attached to the data object given key, then |
|
109 | + * this will throw an exception. |
|
110 | + * |
|
111 | + * @param string $key Key to attach data to. |
|
112 | + * @param string|array $value Value being registered. |
|
113 | + * @throws InvalidArgumentException |
|
114 | + */ |
|
115 | + public function pushData($key, $value) |
|
116 | + { |
|
117 | + if (isset($this->jsdata[$key]) |
|
118 | + && ! is_array($this->jsdata[$key]) |
|
119 | + ) { |
|
120 | + throw new invalidArgumentException( |
|
121 | + sprintf( |
|
122 | + __( |
|
123 | + 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
124 | 124 | push values to this data element when it is an array.', |
125 | - 'event_espresso' |
|
126 | - ), |
|
127 | - $key, |
|
128 | - __METHOD__ |
|
129 | - ) |
|
130 | - ); |
|
131 | - } |
|
132 | - |
|
133 | - $this->jsdata[$key][] = $value; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * Used to set content used by javascript for a template. |
|
139 | - * Note: Overrides of existing registered templates are not allowed. |
|
140 | - * |
|
141 | - * @param string $template_reference |
|
142 | - * @param string $template_content |
|
143 | - * @throws InvalidArgumentException |
|
144 | - */ |
|
145 | - public function addTemplate($template_reference, $template_content) |
|
146 | - { |
|
147 | - if (! isset($this->jsdata['templates'])) { |
|
148 | - $this->jsdata['templates'] = array(); |
|
149 | - } |
|
150 | - |
|
151 | - //no overrides allowed. |
|
152 | - if (isset($this->jsdata['templates'][$template_reference])) { |
|
153 | - throw new invalidArgumentException( |
|
154 | - sprintf( |
|
155 | - __( |
|
156 | - 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
157 | - 'event_espresso' |
|
158 | - ), |
|
159 | - $template_reference |
|
160 | - ) |
|
161 | - ); |
|
162 | - } else { |
|
163 | - $this->jsdata['templates'][$template_reference] = $template_content; |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * Retrieve the template content already registered for the given reference. |
|
170 | - * @param string $template_reference |
|
171 | - * @return string |
|
172 | - */ |
|
173 | - public function getTemplate($template_reference) |
|
174 | - { |
|
175 | - return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
176 | - ? $this->jsdata['templates'][$template_reference] |
|
177 | - : ''; |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * Retrieve registered data. |
|
183 | - * |
|
184 | - * @param string $key Name of key to attach data to. |
|
185 | - * @return mixed If there is no for the given key, then false is returned. |
|
186 | - */ |
|
187 | - public function getData($key) |
|
188 | - { |
|
189 | - return isset($this->jsdata[$key]) |
|
190 | - ? $this->jsdata[$key] |
|
191 | - : false; |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * Verifies whether the given data exists already on the jsdata array. |
|
199 | - * |
|
200 | - * Overriding data is not allowed. |
|
201 | - * |
|
202 | - * @param string $key Index for data. |
|
203 | - * @return bool If valid then return true. |
|
204 | - * @throws InvalidArgumentException if data already exists. |
|
205 | - */ |
|
206 | - protected function verifyDataNotExisting($key) |
|
207 | - { |
|
208 | - if (isset($this->jsdata[$key])) { |
|
209 | - if (is_array($this->jsdata[$key])) { |
|
210 | - throw new InvalidArgumentException( |
|
211 | - sprintf( |
|
212 | - __( |
|
213 | - 'The value for %1$s already exists in the Registry::eejs object. |
|
125 | + 'event_espresso' |
|
126 | + ), |
|
127 | + $key, |
|
128 | + __METHOD__ |
|
129 | + ) |
|
130 | + ); |
|
131 | + } |
|
132 | + |
|
133 | + $this->jsdata[$key][] = $value; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * Used to set content used by javascript for a template. |
|
139 | + * Note: Overrides of existing registered templates are not allowed. |
|
140 | + * |
|
141 | + * @param string $template_reference |
|
142 | + * @param string $template_content |
|
143 | + * @throws InvalidArgumentException |
|
144 | + */ |
|
145 | + public function addTemplate($template_reference, $template_content) |
|
146 | + { |
|
147 | + if (! isset($this->jsdata['templates'])) { |
|
148 | + $this->jsdata['templates'] = array(); |
|
149 | + } |
|
150 | + |
|
151 | + //no overrides allowed. |
|
152 | + if (isset($this->jsdata['templates'][$template_reference])) { |
|
153 | + throw new invalidArgumentException( |
|
154 | + sprintf( |
|
155 | + __( |
|
156 | + 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
157 | + 'event_espresso' |
|
158 | + ), |
|
159 | + $template_reference |
|
160 | + ) |
|
161 | + ); |
|
162 | + } else { |
|
163 | + $this->jsdata['templates'][$template_reference] = $template_content; |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * Retrieve the template content already registered for the given reference. |
|
170 | + * @param string $template_reference |
|
171 | + * @return string |
|
172 | + */ |
|
173 | + public function getTemplate($template_reference) |
|
174 | + { |
|
175 | + return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
176 | + ? $this->jsdata['templates'][$template_reference] |
|
177 | + : ''; |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * Retrieve registered data. |
|
183 | + * |
|
184 | + * @param string $key Name of key to attach data to. |
|
185 | + * @return mixed If there is no for the given key, then false is returned. |
|
186 | + */ |
|
187 | + public function getData($key) |
|
188 | + { |
|
189 | + return isset($this->jsdata[$key]) |
|
190 | + ? $this->jsdata[$key] |
|
191 | + : false; |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * Verifies whether the given data exists already on the jsdata array. |
|
199 | + * |
|
200 | + * Overriding data is not allowed. |
|
201 | + * |
|
202 | + * @param string $key Index for data. |
|
203 | + * @return bool If valid then return true. |
|
204 | + * @throws InvalidArgumentException if data already exists. |
|
205 | + */ |
|
206 | + protected function verifyDataNotExisting($key) |
|
207 | + { |
|
208 | + if (isset($this->jsdata[$key])) { |
|
209 | + if (is_array($this->jsdata[$key])) { |
|
210 | + throw new InvalidArgumentException( |
|
211 | + sprintf( |
|
212 | + __( |
|
213 | + 'The value for %1$s already exists in the Registry::eejs object. |
|
214 | 214 | Overrides are not allowed. Since the value of this data is an array, you may want to use the |
215 | 215 | %2$s method to push your value to the array.', |
216 | - 'event_espresso' |
|
217 | - ), |
|
218 | - $key, |
|
219 | - 'pushData()' |
|
220 | - ) |
|
221 | - ); |
|
222 | - } else { |
|
223 | - throw new InvalidArgumentException( |
|
224 | - sprintf( |
|
225 | - __( |
|
226 | - 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
216 | + 'event_espresso' |
|
217 | + ), |
|
218 | + $key, |
|
219 | + 'pushData()' |
|
220 | + ) |
|
221 | + ); |
|
222 | + } else { |
|
223 | + throw new InvalidArgumentException( |
|
224 | + sprintf( |
|
225 | + __( |
|
226 | + 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
227 | 227 | allowed. Consider attaching your value to a different key', |
228 | - 'event_espresso' |
|
229 | - ), |
|
230 | - $key |
|
231 | - ) |
|
232 | - ); |
|
233 | - } |
|
234 | - } |
|
235 | - return true; |
|
236 | - } |
|
228 | + 'event_espresso' |
|
229 | + ), |
|
230 | + $key |
|
231 | + ) |
|
232 | + ); |
|
233 | + } |
|
234 | + } |
|
235 | + return true; |
|
236 | + } |
|
237 | 237 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | global $wp_version; |
45 | 45 | wp_register_script( |
46 | 46 | 'eejs-core', |
47 | - EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
47 | + EE_PLUGIN_DIR_URL.'core/services/assets/core_assets/eejs-core.js', |
|
48 | 48 | array(), |
49 | 49 | espresso_version(), |
50 | 50 | true |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | //js.api |
55 | 55 | wp_register_script( |
56 | 56 | 'eejs-api', |
57 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
57 | + EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js', |
|
58 | 58 | array('underscore', 'eejs-core'), |
59 | 59 | espresso_version(), |
60 | 60 | true |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function addTemplate($template_reference, $template_content) |
146 | 146 | { |
147 | - if (! isset($this->jsdata['templates'])) { |
|
147 | + if ( ! isset($this->jsdata['templates'])) { |
|
148 | 148 | $this->jsdata['templates'] = array(); |
149 | 149 | } |
150 | 150 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\modules\ticket_selector; |
3 | 3 | |
4 | 4 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
5 | - exit( 'No direct script access allowed' ); |
|
5 | + exit( 'No direct script access allowed' ); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,667 +19,667 @@ discard block |
||
19 | 19 | class DisplayTicketSelector |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * event that ticket selector is being generated for |
|
24 | - * |
|
25 | - * @access protected |
|
26 | - * @var \EE_Event $event |
|
27 | - */ |
|
28 | - protected $event; |
|
29 | - |
|
30 | - /** |
|
31 | - * Used to flag when the ticket selector is being called from an external iframe. |
|
32 | - * |
|
33 | - * @var bool $iframe |
|
34 | - */ |
|
35 | - protected $iframe = false; |
|
36 | - |
|
37 | - /** |
|
38 | - * max attendees that can register for event at one time |
|
39 | - * |
|
40 | - * @var int $max_attendees |
|
41 | - */ |
|
42 | - private $max_attendees = EE_INF; |
|
43 | - |
|
44 | - /** |
|
45 | - *@var string $date_format |
|
46 | - */ |
|
47 | - private $date_format = ''; |
|
48 | - |
|
49 | - /** |
|
50 | - *@var string $time_format |
|
51 | - */ |
|
52 | - private $time_format = ''; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * DisplayTicketSelector constructor. |
|
58 | - */ |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - $this->date_format = apply_filters( |
|
62 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
63 | - get_option('date_format') |
|
64 | - ); |
|
65 | - $this->time_format = apply_filters( |
|
66 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
67 | - get_option('time_format') |
|
68 | - ); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @param boolean $iframe |
|
75 | - */ |
|
76 | - public function setIframe( $iframe = true ) |
|
77 | - { |
|
78 | - $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * finds and sets the \EE_Event object for use throughout class |
|
85 | - * |
|
86 | - * @param mixed $event |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - protected function setEvent( $event = null ) |
|
90 | - { |
|
91 | - if ( $event === null ) { |
|
92 | - global $post; |
|
93 | - $event = $post; |
|
94 | - } |
|
95 | - if ( $event instanceof \EE_Event ) { |
|
96 | - $this->event = $event; |
|
97 | - } else if ( $event instanceof \WP_Post ) { |
|
98 | - if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) { |
|
99 | - $this->event = $event->EE_Event; |
|
100 | - } else if ( $event->post_type === 'espresso_events' ) { |
|
101 | - $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
102 | - $this->event = $event->EE_Event; |
|
103 | - } |
|
104 | - } else { |
|
105 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
106 | - $dev_msg = $user_msg . __( |
|
107 | - 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
108 | - 'event_espresso' |
|
109 | - ); |
|
110 | - \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | - return false; |
|
112 | - } |
|
113 | - return true; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return int |
|
120 | - */ |
|
121 | - public function getMaxAttendees() |
|
122 | - { |
|
123 | - return $this->max_attendees; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @param int $max_attendees |
|
130 | - */ |
|
131 | - public function setMaxAttendees($max_attendees) |
|
132 | - { |
|
133 | - $this->max_attendees = absint( |
|
134 | - apply_filters( |
|
135 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
136 | - $max_attendees |
|
137 | - ) |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * creates buttons for selecting number of attendees for an event |
|
145 | - * |
|
146 | - * @param \WP_Post|int $event |
|
147 | - * @param bool $view_details |
|
148 | - * @return string |
|
149 | - * @throws \EE_Error |
|
150 | - */ |
|
151 | - public function display( $event = null, $view_details = false ) |
|
152 | - { |
|
153 | - // reset filter for displaying submit button |
|
154 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
155 | - // poke and prod incoming event till it tells us what it is |
|
156 | - if ( ! $this->setEvent( $event ) ) { |
|
157 | - return false; |
|
158 | - } |
|
159 | - // begin gathering template arguments by getting event status |
|
160 | - $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
161 | - if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
162 | - return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
163 | - } |
|
164 | - // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
165 | - $this->setMaxAttendees($this->event->additional_limit()); |
|
166 | - if ($this->getMaxAttendees() < 1) { |
|
167 | - return $this->ticketSalesClosedMessage(); |
|
168 | - } |
|
169 | - // is the event expired ? |
|
170 | - $template_args['event_is_expired'] = $this->event->is_expired(); |
|
171 | - if ( $template_args[ 'event_is_expired' ] ) { |
|
172 | - return $this->expiredEventMessage(); |
|
173 | - } |
|
174 | - // get all tickets for this event ordered by the datetime |
|
175 | - $tickets = $this->getTickets(); |
|
176 | - if (count($tickets) < 1) { |
|
177 | - return $this->noTicketAvailableMessage(); |
|
178 | - } |
|
179 | - // redirecting to another site for registration ?? |
|
180 | - $external_url = (string) $this->event->external_url(); |
|
181 | - // if redirecting to another site for registration, then we don't load the TS |
|
182 | - $ticket_selector = $external_url |
|
183 | - ? $this->externalEventRegistration() |
|
184 | - : $this->loadTicketSelector($tickets,$template_args); |
|
185 | - // now set up the form (but not for the admin) |
|
186 | - $ticket_selector = ! is_admin() |
|
187 | - ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
188 | - : $ticket_selector; |
|
189 | - // submit button and form close tag |
|
190 | - $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
|
191 | - return $ticket_selector; |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * displayTicketSelector |
|
198 | - * examines the event properties and determines whether a Ticket Selector should be displayed |
|
199 | - * |
|
200 | - * @param \WP_Post|int $event |
|
201 | - * @param string $_event_active_status |
|
202 | - * @param bool $view_details |
|
203 | - * @return bool |
|
204 | - * @throws \EE_Error |
|
205 | - */ |
|
206 | - protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
207 | - { |
|
208 | - $event_post = $this->event instanceof \EE_Event ? $this->event->ID() : $event; |
|
209 | - return ! is_admin() |
|
210 | - && ( |
|
211 | - ! $this->event->display_ticket_selector() |
|
212 | - || $view_details |
|
213 | - || post_password_required($event_post) |
|
214 | - || ( |
|
215 | - $_event_active_status !== \EE_Datetime::active |
|
216 | - && $_event_active_status !== \EE_Datetime::upcoming |
|
217 | - && $_event_active_status !== \EE_Datetime::sold_out |
|
218 | - && ! ( |
|
219 | - $_event_active_status === \EE_Datetime::inactive |
|
220 | - && is_user_logged_in() |
|
221 | - ) |
|
222 | - ) |
|
223 | - ); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * noTicketAvailableMessage |
|
230 | - * notice displayed if event is expired |
|
231 | - * |
|
232 | - * @return string |
|
233 | - * @throws \EE_Error |
|
234 | - */ |
|
235 | - protected function expiredEventMessage() |
|
236 | - { |
|
237 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
238 | - 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
239 | - 'event_espresso' |
|
240 | - ) . '</span></div>'; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * noTicketAvailableMessage |
|
247 | - * notice displayed if event has no more tickets available |
|
248 | - * |
|
249 | - * @return string |
|
250 | - * @throws \EE_Error |
|
251 | - */ |
|
252 | - protected function noTicketAvailableMessage() |
|
253 | - { |
|
254 | - $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
255 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
256 | - $no_ticket_available_msg .= sprintf( |
|
257 | - esc_html__( |
|
258 | - '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
259 | - 'event_espresso' |
|
260 | - ), |
|
261 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
262 | - '</b><br />', |
|
263 | - '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
264 | - '</a></span></div>' |
|
265 | - ); |
|
266 | - } |
|
267 | - return ' |
|
22 | + /** |
|
23 | + * event that ticket selector is being generated for |
|
24 | + * |
|
25 | + * @access protected |
|
26 | + * @var \EE_Event $event |
|
27 | + */ |
|
28 | + protected $event; |
|
29 | + |
|
30 | + /** |
|
31 | + * Used to flag when the ticket selector is being called from an external iframe. |
|
32 | + * |
|
33 | + * @var bool $iframe |
|
34 | + */ |
|
35 | + protected $iframe = false; |
|
36 | + |
|
37 | + /** |
|
38 | + * max attendees that can register for event at one time |
|
39 | + * |
|
40 | + * @var int $max_attendees |
|
41 | + */ |
|
42 | + private $max_attendees = EE_INF; |
|
43 | + |
|
44 | + /** |
|
45 | + *@var string $date_format |
|
46 | + */ |
|
47 | + private $date_format = ''; |
|
48 | + |
|
49 | + /** |
|
50 | + *@var string $time_format |
|
51 | + */ |
|
52 | + private $time_format = ''; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * DisplayTicketSelector constructor. |
|
58 | + */ |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + $this->date_format = apply_filters( |
|
62 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
63 | + get_option('date_format') |
|
64 | + ); |
|
65 | + $this->time_format = apply_filters( |
|
66 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
67 | + get_option('time_format') |
|
68 | + ); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @param boolean $iframe |
|
75 | + */ |
|
76 | + public function setIframe( $iframe = true ) |
|
77 | + { |
|
78 | + $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * finds and sets the \EE_Event object for use throughout class |
|
85 | + * |
|
86 | + * @param mixed $event |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + protected function setEvent( $event = null ) |
|
90 | + { |
|
91 | + if ( $event === null ) { |
|
92 | + global $post; |
|
93 | + $event = $post; |
|
94 | + } |
|
95 | + if ( $event instanceof \EE_Event ) { |
|
96 | + $this->event = $event; |
|
97 | + } else if ( $event instanceof \WP_Post ) { |
|
98 | + if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) { |
|
99 | + $this->event = $event->EE_Event; |
|
100 | + } else if ( $event->post_type === 'espresso_events' ) { |
|
101 | + $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
102 | + $this->event = $event->EE_Event; |
|
103 | + } |
|
104 | + } else { |
|
105 | + $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
106 | + $dev_msg = $user_msg . __( |
|
107 | + 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
108 | + 'event_espresso' |
|
109 | + ); |
|
110 | + \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | + return false; |
|
112 | + } |
|
113 | + return true; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return int |
|
120 | + */ |
|
121 | + public function getMaxAttendees() |
|
122 | + { |
|
123 | + return $this->max_attendees; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @param int $max_attendees |
|
130 | + */ |
|
131 | + public function setMaxAttendees($max_attendees) |
|
132 | + { |
|
133 | + $this->max_attendees = absint( |
|
134 | + apply_filters( |
|
135 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
136 | + $max_attendees |
|
137 | + ) |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * creates buttons for selecting number of attendees for an event |
|
145 | + * |
|
146 | + * @param \WP_Post|int $event |
|
147 | + * @param bool $view_details |
|
148 | + * @return string |
|
149 | + * @throws \EE_Error |
|
150 | + */ |
|
151 | + public function display( $event = null, $view_details = false ) |
|
152 | + { |
|
153 | + // reset filter for displaying submit button |
|
154 | + remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
155 | + // poke and prod incoming event till it tells us what it is |
|
156 | + if ( ! $this->setEvent( $event ) ) { |
|
157 | + return false; |
|
158 | + } |
|
159 | + // begin gathering template arguments by getting event status |
|
160 | + $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
161 | + if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
162 | + return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
163 | + } |
|
164 | + // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
165 | + $this->setMaxAttendees($this->event->additional_limit()); |
|
166 | + if ($this->getMaxAttendees() < 1) { |
|
167 | + return $this->ticketSalesClosedMessage(); |
|
168 | + } |
|
169 | + // is the event expired ? |
|
170 | + $template_args['event_is_expired'] = $this->event->is_expired(); |
|
171 | + if ( $template_args[ 'event_is_expired' ] ) { |
|
172 | + return $this->expiredEventMessage(); |
|
173 | + } |
|
174 | + // get all tickets for this event ordered by the datetime |
|
175 | + $tickets = $this->getTickets(); |
|
176 | + if (count($tickets) < 1) { |
|
177 | + return $this->noTicketAvailableMessage(); |
|
178 | + } |
|
179 | + // redirecting to another site for registration ?? |
|
180 | + $external_url = (string) $this->event->external_url(); |
|
181 | + // if redirecting to another site for registration, then we don't load the TS |
|
182 | + $ticket_selector = $external_url |
|
183 | + ? $this->externalEventRegistration() |
|
184 | + : $this->loadTicketSelector($tickets,$template_args); |
|
185 | + // now set up the form (but not for the admin) |
|
186 | + $ticket_selector = ! is_admin() |
|
187 | + ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
188 | + : $ticket_selector; |
|
189 | + // submit button and form close tag |
|
190 | + $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
|
191 | + return $ticket_selector; |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * displayTicketSelector |
|
198 | + * examines the event properties and determines whether a Ticket Selector should be displayed |
|
199 | + * |
|
200 | + * @param \WP_Post|int $event |
|
201 | + * @param string $_event_active_status |
|
202 | + * @param bool $view_details |
|
203 | + * @return bool |
|
204 | + * @throws \EE_Error |
|
205 | + */ |
|
206 | + protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
207 | + { |
|
208 | + $event_post = $this->event instanceof \EE_Event ? $this->event->ID() : $event; |
|
209 | + return ! is_admin() |
|
210 | + && ( |
|
211 | + ! $this->event->display_ticket_selector() |
|
212 | + || $view_details |
|
213 | + || post_password_required($event_post) |
|
214 | + || ( |
|
215 | + $_event_active_status !== \EE_Datetime::active |
|
216 | + && $_event_active_status !== \EE_Datetime::upcoming |
|
217 | + && $_event_active_status !== \EE_Datetime::sold_out |
|
218 | + && ! ( |
|
219 | + $_event_active_status === \EE_Datetime::inactive |
|
220 | + && is_user_logged_in() |
|
221 | + ) |
|
222 | + ) |
|
223 | + ); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * noTicketAvailableMessage |
|
230 | + * notice displayed if event is expired |
|
231 | + * |
|
232 | + * @return string |
|
233 | + * @throws \EE_Error |
|
234 | + */ |
|
235 | + protected function expiredEventMessage() |
|
236 | + { |
|
237 | + return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
238 | + 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
239 | + 'event_espresso' |
|
240 | + ) . '</span></div>'; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * noTicketAvailableMessage |
|
247 | + * notice displayed if event has no more tickets available |
|
248 | + * |
|
249 | + * @return string |
|
250 | + * @throws \EE_Error |
|
251 | + */ |
|
252 | + protected function noTicketAvailableMessage() |
|
253 | + { |
|
254 | + $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
255 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
256 | + $no_ticket_available_msg .= sprintf( |
|
257 | + esc_html__( |
|
258 | + '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
259 | + 'event_espresso' |
|
260 | + ), |
|
261 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
262 | + '</b><br />', |
|
263 | + '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
264 | + '</a></span></div>' |
|
265 | + ); |
|
266 | + } |
|
267 | + return ' |
|
268 | 268 | <div class="ee-event-expired-notice"> |
269 | 269 | <span class="important-notice">' . $no_ticket_available_msg . '</span> |
270 | 270 | </div>'; |
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * ticketSalesClosed |
|
277 | - * notice displayed if event ticket sales are turned off |
|
278 | - * |
|
279 | - * @return string |
|
280 | - * @throws \EE_Error |
|
281 | - */ |
|
282 | - protected function ticketSalesClosedMessage() |
|
283 | - { |
|
284 | - $sales_closed_msg = esc_html__( |
|
285 | - 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
286 | - 'event_espresso' |
|
287 | - ); |
|
288 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
289 | - $sales_closed_msg .= sprintf( |
|
290 | - esc_html__( |
|
291 | - '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
292 | - 'event_espresso' |
|
293 | - ), |
|
294 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
295 | - '</b><br />', |
|
296 | - '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
297 | - '</a></span></div>' |
|
298 | - ); |
|
299 | - } |
|
300 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * getTickets |
|
307 | - * |
|
308 | - * @return \EE_Base_Class[]|\EE_Ticket[] |
|
309 | - * @throws \EE_Error |
|
310 | - */ |
|
311 | - protected function getTickets() |
|
312 | - { |
|
313 | - $ticket_query_args = array( |
|
314 | - array('Datetime.EVT_ID' => $this->event->ID()), |
|
315 | - 'order_by' => array( |
|
316 | - 'TKT_order' => 'ASC', |
|
317 | - 'TKT_required' => 'DESC', |
|
318 | - 'TKT_start_date' => 'ASC', |
|
319 | - 'TKT_end_date' => 'ASC', |
|
320 | - 'Datetime.DTT_EVT_start' => 'DESC', |
|
321 | - ), |
|
322 | - ); |
|
323 | - if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
324 | - //use the correct applicable time query depending on what version of core is being run. |
|
325 | - $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
326 | - ? time() |
|
327 | - : current_time('timestamp'); |
|
328 | - $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
329 | - } |
|
330 | - return \EEM_Ticket::instance()->get_all($ticket_query_args); |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * loadTicketSelector |
|
337 | - * begins to assemble template arguments |
|
338 | - * and decides whether to load a "simple" ticket selector, or the standard |
|
339 | - * |
|
340 | - * @param \EE_Ticket[] $tickets |
|
341 | - * @param array $template_args |
|
342 | - * @return string |
|
343 | - * @throws \EE_Error |
|
344 | - */ |
|
345 | - protected function loadTicketSelector(array $tickets, array $template_args) |
|
346 | - { |
|
347 | - $template_args['event'] = $this->event; |
|
348 | - $template_args['EVT_ID'] = $this->event->ID(); |
|
349 | - $template_args['event_is_expired'] = $this->event->is_expired(); |
|
350 | - $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
351 | - $template_args['date_format'] = $this->date_format; |
|
352 | - $template_args['time_format'] = $this->time_format; |
|
353 | - /** |
|
354 | - * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
355 | - * |
|
356 | - * @since 4.9.13 |
|
357 | - * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
358 | - * @param int $EVT_ID The Event ID |
|
359 | - */ |
|
360 | - $template_args['anchor_id'] = apply_filters( |
|
361 | - 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
362 | - '#tkt-slctr-tbl-' . $this->event->ID(), |
|
363 | - $this->event->ID() |
|
364 | - ); |
|
365 | - $template_args['tickets'] = $tickets; |
|
366 | - $template_args['ticket_count'] = count($tickets); |
|
367 | - $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
368 | - return $ticket_selector instanceof TicketSelectorSimple |
|
369 | - ? $ticket_selector |
|
370 | - : new TicketSelectorStandard( |
|
371 | - $this->event, |
|
372 | - $tickets, |
|
373 | - $this->getMaxAttendees(), |
|
374 | - $template_args, |
|
375 | - $this->date_format, |
|
376 | - $this->time_format |
|
377 | - ); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * simpleTicketSelector |
|
384 | - * there's one ticket, and max attendees is set to one, |
|
385 | - * so if the event is free, then this is a "simple" ticket selector |
|
386 | - * a.k.a. "Dude Where's my Ticket Selector?" |
|
387 | - * |
|
388 | - * @param \EE_Ticket[] $tickets |
|
389 | - * @param array $template_args |
|
390 | - * @return string |
|
391 | - * @throws \EE_Error |
|
392 | - */ |
|
393 | - protected function simpleTicketSelector($tickets, array $template_args) |
|
394 | - { |
|
395 | - // if there is only ONE ticket with a max qty of ONE |
|
396 | - if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
397 | - return ''; |
|
398 | - } |
|
399 | - /** @var \EE_Ticket $ticket */ |
|
400 | - $ticket = reset($tickets); |
|
401 | - // if the ticket is free... then not much need for the ticket selector |
|
402 | - if ( |
|
403 | - apply_filters( |
|
404 | - 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
405 | - $ticket->is_free(), |
|
406 | - $this->event->ID() |
|
407 | - ) |
|
408 | - ) { |
|
409 | - return new TicketSelectorSimple( |
|
410 | - $this->event, |
|
411 | - $ticket, |
|
412 | - $this->getMaxAttendees(), |
|
413 | - $template_args |
|
414 | - ); |
|
415 | - } |
|
416 | - return ''; |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * externalEventRegistration |
|
423 | - * |
|
424 | - * @return string |
|
425 | - */ |
|
426 | - public function externalEventRegistration() |
|
427 | - { |
|
428 | - // if not we still need to trigger the display of the submit button |
|
429 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
430 | - //display notice to admin that registration is external |
|
431 | - return is_admin() |
|
432 | - ? esc_html__( |
|
433 | - 'Registration is at an external URL for this event.', |
|
434 | - 'event_espresso' |
|
435 | - ) |
|
436 | - : ''; |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * formOpen |
|
443 | - * |
|
444 | - * @param int $ID |
|
445 | - * @param string $external_url |
|
446 | - * @return string |
|
447 | - */ |
|
448 | - public function formOpen( $ID = 0, $external_url = '' ) |
|
449 | - { |
|
450 | - // if redirecting, we don't need any anything else |
|
451 | - if ( $external_url ) { |
|
452 | - $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"'; |
|
453 | - // open link in new window ? |
|
454 | - $html .= apply_filters( |
|
455 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
456 | - false |
|
457 | - ) |
|
458 | - ? ' target="_blank"' |
|
459 | - : ''; |
|
460 | - $html .= '>'; |
|
461 | - $query_args = \EEH_URL::get_query_string( $external_url ); |
|
462 | - foreach ( (array)$query_args as $query_arg => $value ) { |
|
463 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
464 | - } |
|
465 | - return $html; |
|
466 | - } |
|
467 | - // if there is no submit button, then don't start building a form |
|
468 | - // because the "View Details" button will build its own form |
|
469 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
470 | - return ''; |
|
471 | - } |
|
472 | - $checkout_url = \EEH_Event_View::event_link_url( $ID ); |
|
473 | - if ( ! $checkout_url ) { |
|
474 | - \EE_Error::add_error( |
|
475 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
476 | - __FILE__, |
|
477 | - __FUNCTION__, |
|
478 | - __LINE__ |
|
479 | - ); |
|
480 | - } |
|
481 | - // set no cache headers and constants |
|
482 | - \EE_System::do_not_cache(); |
|
483 | - $extra_params = $this->iframe ? ' target="_blank"' : ''; |
|
484 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
485 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false ); |
|
486 | - $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
487 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
488 | - return $html; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - |
|
493 | - /** |
|
494 | - * displaySubmitButton |
|
495 | - * |
|
496 | - * @param string $external_url |
|
497 | - * @return string |
|
498 | - * @throws \EE_Error |
|
499 | - */ |
|
500 | - public function displaySubmitButton($external_url = '') |
|
501 | - { |
|
502 | - $html = ''; |
|
503 | - if ( ! is_admin()) { |
|
504 | - // standard TS displayed with submit button, ie: "Register Now" |
|
505 | - if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
506 | - $html .= $this->displayRegisterNowButton(); |
|
507 | - $html .= empty($external_url) |
|
508 | - ? $this->ticketSelectorEndDiv() |
|
509 | - : $this->clearTicketSelector(); |
|
510 | - $html .= '<br/>' . $this->formClose(); |
|
511 | - } else if ($this->getMaxAttendees() === 1) { |
|
512 | - // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
513 | - if ($this->event->is_sold_out()) { |
|
514 | - // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
515 | - $html .= apply_filters( |
|
516 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
517 | - sprintf( |
|
518 | - __( |
|
519 | - '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
520 | - 'event_espresso' |
|
521 | - ), |
|
522 | - '<p class="no-ticket-selector-msg clear-float">', |
|
523 | - $this->event->name(), |
|
524 | - '</p>', |
|
525 | - '<br />' |
|
526 | - ), |
|
527 | - $this->event |
|
528 | - ); |
|
529 | - if ( |
|
530 | - apply_filters( |
|
531 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
532 | - false, |
|
533 | - $this->event |
|
534 | - ) |
|
535 | - ) { |
|
536 | - $html .= $this->displayRegisterNowButton(); |
|
537 | - } |
|
538 | - // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
539 | - $html .= $this->ticketSelectorEndDiv(); |
|
540 | - } else if ( |
|
541 | - apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
542 | - && ! is_single() |
|
543 | - ) { |
|
544 | - // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
545 | - // but no tickets are available, so display event's "View Details" button. |
|
546 | - // it is being viewed via somewhere other than a single post |
|
547 | - $html .= $this->displayViewDetailsButton(true); |
|
548 | - } |
|
549 | - } else if (is_archive()) { |
|
550 | - // event list, no tickets available so display event's "View Details" button |
|
551 | - $html .= $this->ticketSelectorEndDiv(); |
|
552 | - $html .= $this->displayViewDetailsButton(); |
|
553 | - } else { |
|
554 | - if ( |
|
555 | - apply_filters( |
|
556 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
557 | - false, |
|
558 | - $this->event |
|
559 | - ) |
|
560 | - ) { |
|
561 | - $html .= $this->displayRegisterNowButton(); |
|
562 | - } |
|
563 | - // no submit or view details button, and no additional content |
|
564 | - $html .= $this->ticketSelectorEndDiv(); |
|
565 | - } |
|
566 | - if ( ! $this->iframe && ! is_archive()) { |
|
567 | - $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector')); |
|
568 | - } |
|
569 | - } |
|
570 | - return $html; |
|
571 | - } |
|
572 | - |
|
573 | - |
|
574 | - |
|
575 | - /** |
|
576 | - * @return string |
|
577 | - * @throws \EE_Error |
|
578 | - */ |
|
579 | - public function displayRegisterNowButton() |
|
580 | - { |
|
581 | - $btn_text = apply_filters( |
|
582 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
583 | - __('Register Now', 'event_espresso'), |
|
584 | - $this->event |
|
585 | - ); |
|
586 | - $external_url = $this->event->external_url(); |
|
587 | - $html = \EEH_HTML::div( |
|
588 | - '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
589 | - ); |
|
590 | - $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
591 | - $html .= ' class="ticket-selector-submit-btn '; |
|
592 | - $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
593 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
594 | - $html .= \EEH_HTML::divx(); |
|
595 | - $html .= apply_filters( |
|
596 | - 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
597 | - '', |
|
598 | - $this->event |
|
599 | - ); |
|
600 | - return $html; |
|
601 | - } |
|
602 | - |
|
603 | - |
|
604 | - /** |
|
605 | - * displayViewDetailsButton |
|
606 | - * |
|
607 | - * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
608 | - * (ie: $_max_atndz === 1) where there are no available tickets, |
|
609 | - * either because they are sold out, expired, or not yet on sale. |
|
610 | - * In this case, we need to close the form BEFORE adding any closing divs |
|
611 | - * @return string |
|
612 | - * @throws \EE_Error |
|
613 | - */ |
|
614 | - public function displayViewDetailsButton( $DWMTS = false ) |
|
615 | - { |
|
616 | - if ( ! $this->event->get_permalink() ) { |
|
617 | - \EE_Error::add_error( |
|
618 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
619 | - __FILE__, __FUNCTION__, __LINE__ |
|
620 | - ); |
|
621 | - } |
|
622 | - $view_details_btn = '<form method="POST" action="'; |
|
623 | - $view_details_btn .= apply_filters( |
|
624 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
625 | - $this->event->get_permalink(), |
|
626 | - $this->event |
|
627 | - ); |
|
628 | - $view_details_btn .= '">'; |
|
629 | - $btn_text = apply_filters( |
|
630 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
631 | - esc_html__('View Details', 'event_espresso'), |
|
632 | - $this->event |
|
633 | - ); |
|
634 | - $view_details_btn .= '<input id="ticket-selector-submit-' |
|
635 | - . $this->event->ID() |
|
636 | - . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
637 | - . $btn_text |
|
638 | - . '" />'; |
|
639 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
640 | - if ($DWMTS) { |
|
641 | - $view_details_btn .= $this->formClose(); |
|
642 | - $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
643 | - $view_details_btn .= '<br/>'; |
|
644 | - } else { |
|
645 | - $view_details_btn .= $this->clearTicketSelector(); |
|
646 | - $view_details_btn .= '<br/>'; |
|
647 | - $view_details_btn .= $this->formClose(); |
|
648 | - } |
|
649 | - return $view_details_btn; |
|
650 | - } |
|
651 | - |
|
652 | - |
|
653 | - |
|
654 | - /** |
|
655 | - * @return string |
|
656 | - */ |
|
657 | - public function ticketSelectorEndDiv() |
|
658 | - { |
|
659 | - return '<div class="clear"></div></div>'; |
|
660 | - } |
|
661 | - |
|
662 | - |
|
663 | - |
|
664 | - /** |
|
665 | - * @return string |
|
666 | - */ |
|
667 | - public function clearTicketSelector() |
|
668 | - { |
|
669 | - // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
670 | - return '<div class="clear"></div>'; |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - |
|
675 | - /** |
|
676 | - * @access public |
|
677 | - * @return string |
|
678 | - */ |
|
679 | - public function formClose() |
|
680 | - { |
|
681 | - return '</form>'; |
|
682 | - } |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * ticketSalesClosed |
|
277 | + * notice displayed if event ticket sales are turned off |
|
278 | + * |
|
279 | + * @return string |
|
280 | + * @throws \EE_Error |
|
281 | + */ |
|
282 | + protected function ticketSalesClosedMessage() |
|
283 | + { |
|
284 | + $sales_closed_msg = esc_html__( |
|
285 | + 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
286 | + 'event_espresso' |
|
287 | + ); |
|
288 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
289 | + $sales_closed_msg .= sprintf( |
|
290 | + esc_html__( |
|
291 | + '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
292 | + 'event_espresso' |
|
293 | + ), |
|
294 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
295 | + '</b><br />', |
|
296 | + '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
297 | + '</a></span></div>' |
|
298 | + ); |
|
299 | + } |
|
300 | + return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * getTickets |
|
307 | + * |
|
308 | + * @return \EE_Base_Class[]|\EE_Ticket[] |
|
309 | + * @throws \EE_Error |
|
310 | + */ |
|
311 | + protected function getTickets() |
|
312 | + { |
|
313 | + $ticket_query_args = array( |
|
314 | + array('Datetime.EVT_ID' => $this->event->ID()), |
|
315 | + 'order_by' => array( |
|
316 | + 'TKT_order' => 'ASC', |
|
317 | + 'TKT_required' => 'DESC', |
|
318 | + 'TKT_start_date' => 'ASC', |
|
319 | + 'TKT_end_date' => 'ASC', |
|
320 | + 'Datetime.DTT_EVT_start' => 'DESC', |
|
321 | + ), |
|
322 | + ); |
|
323 | + if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
324 | + //use the correct applicable time query depending on what version of core is being run. |
|
325 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
326 | + ? time() |
|
327 | + : current_time('timestamp'); |
|
328 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
329 | + } |
|
330 | + return \EEM_Ticket::instance()->get_all($ticket_query_args); |
|
331 | + } |
|
332 | + |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * loadTicketSelector |
|
337 | + * begins to assemble template arguments |
|
338 | + * and decides whether to load a "simple" ticket selector, or the standard |
|
339 | + * |
|
340 | + * @param \EE_Ticket[] $tickets |
|
341 | + * @param array $template_args |
|
342 | + * @return string |
|
343 | + * @throws \EE_Error |
|
344 | + */ |
|
345 | + protected function loadTicketSelector(array $tickets, array $template_args) |
|
346 | + { |
|
347 | + $template_args['event'] = $this->event; |
|
348 | + $template_args['EVT_ID'] = $this->event->ID(); |
|
349 | + $template_args['event_is_expired'] = $this->event->is_expired(); |
|
350 | + $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
351 | + $template_args['date_format'] = $this->date_format; |
|
352 | + $template_args['time_format'] = $this->time_format; |
|
353 | + /** |
|
354 | + * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
355 | + * |
|
356 | + * @since 4.9.13 |
|
357 | + * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
358 | + * @param int $EVT_ID The Event ID |
|
359 | + */ |
|
360 | + $template_args['anchor_id'] = apply_filters( |
|
361 | + 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
362 | + '#tkt-slctr-tbl-' . $this->event->ID(), |
|
363 | + $this->event->ID() |
|
364 | + ); |
|
365 | + $template_args['tickets'] = $tickets; |
|
366 | + $template_args['ticket_count'] = count($tickets); |
|
367 | + $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
368 | + return $ticket_selector instanceof TicketSelectorSimple |
|
369 | + ? $ticket_selector |
|
370 | + : new TicketSelectorStandard( |
|
371 | + $this->event, |
|
372 | + $tickets, |
|
373 | + $this->getMaxAttendees(), |
|
374 | + $template_args, |
|
375 | + $this->date_format, |
|
376 | + $this->time_format |
|
377 | + ); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * simpleTicketSelector |
|
384 | + * there's one ticket, and max attendees is set to one, |
|
385 | + * so if the event is free, then this is a "simple" ticket selector |
|
386 | + * a.k.a. "Dude Where's my Ticket Selector?" |
|
387 | + * |
|
388 | + * @param \EE_Ticket[] $tickets |
|
389 | + * @param array $template_args |
|
390 | + * @return string |
|
391 | + * @throws \EE_Error |
|
392 | + */ |
|
393 | + protected function simpleTicketSelector($tickets, array $template_args) |
|
394 | + { |
|
395 | + // if there is only ONE ticket with a max qty of ONE |
|
396 | + if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
397 | + return ''; |
|
398 | + } |
|
399 | + /** @var \EE_Ticket $ticket */ |
|
400 | + $ticket = reset($tickets); |
|
401 | + // if the ticket is free... then not much need for the ticket selector |
|
402 | + if ( |
|
403 | + apply_filters( |
|
404 | + 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
405 | + $ticket->is_free(), |
|
406 | + $this->event->ID() |
|
407 | + ) |
|
408 | + ) { |
|
409 | + return new TicketSelectorSimple( |
|
410 | + $this->event, |
|
411 | + $ticket, |
|
412 | + $this->getMaxAttendees(), |
|
413 | + $template_args |
|
414 | + ); |
|
415 | + } |
|
416 | + return ''; |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * externalEventRegistration |
|
423 | + * |
|
424 | + * @return string |
|
425 | + */ |
|
426 | + public function externalEventRegistration() |
|
427 | + { |
|
428 | + // if not we still need to trigger the display of the submit button |
|
429 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
430 | + //display notice to admin that registration is external |
|
431 | + return is_admin() |
|
432 | + ? esc_html__( |
|
433 | + 'Registration is at an external URL for this event.', |
|
434 | + 'event_espresso' |
|
435 | + ) |
|
436 | + : ''; |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * formOpen |
|
443 | + * |
|
444 | + * @param int $ID |
|
445 | + * @param string $external_url |
|
446 | + * @return string |
|
447 | + */ |
|
448 | + public function formOpen( $ID = 0, $external_url = '' ) |
|
449 | + { |
|
450 | + // if redirecting, we don't need any anything else |
|
451 | + if ( $external_url ) { |
|
452 | + $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"'; |
|
453 | + // open link in new window ? |
|
454 | + $html .= apply_filters( |
|
455 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
456 | + false |
|
457 | + ) |
|
458 | + ? ' target="_blank"' |
|
459 | + : ''; |
|
460 | + $html .= '>'; |
|
461 | + $query_args = \EEH_URL::get_query_string( $external_url ); |
|
462 | + foreach ( (array)$query_args as $query_arg => $value ) { |
|
463 | + $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
464 | + } |
|
465 | + return $html; |
|
466 | + } |
|
467 | + // if there is no submit button, then don't start building a form |
|
468 | + // because the "View Details" button will build its own form |
|
469 | + if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
470 | + return ''; |
|
471 | + } |
|
472 | + $checkout_url = \EEH_Event_View::event_link_url( $ID ); |
|
473 | + if ( ! $checkout_url ) { |
|
474 | + \EE_Error::add_error( |
|
475 | + esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
476 | + __FILE__, |
|
477 | + __FUNCTION__, |
|
478 | + __LINE__ |
|
479 | + ); |
|
480 | + } |
|
481 | + // set no cache headers and constants |
|
482 | + \EE_System::do_not_cache(); |
|
483 | + $extra_params = $this->iframe ? ' target="_blank"' : ''; |
|
484 | + $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
485 | + $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false ); |
|
486 | + $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
487 | + $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
488 | + return $html; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + |
|
493 | + /** |
|
494 | + * displaySubmitButton |
|
495 | + * |
|
496 | + * @param string $external_url |
|
497 | + * @return string |
|
498 | + * @throws \EE_Error |
|
499 | + */ |
|
500 | + public function displaySubmitButton($external_url = '') |
|
501 | + { |
|
502 | + $html = ''; |
|
503 | + if ( ! is_admin()) { |
|
504 | + // standard TS displayed with submit button, ie: "Register Now" |
|
505 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
506 | + $html .= $this->displayRegisterNowButton(); |
|
507 | + $html .= empty($external_url) |
|
508 | + ? $this->ticketSelectorEndDiv() |
|
509 | + : $this->clearTicketSelector(); |
|
510 | + $html .= '<br/>' . $this->formClose(); |
|
511 | + } else if ($this->getMaxAttendees() === 1) { |
|
512 | + // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
513 | + if ($this->event->is_sold_out()) { |
|
514 | + // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
515 | + $html .= apply_filters( |
|
516 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
517 | + sprintf( |
|
518 | + __( |
|
519 | + '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
520 | + 'event_espresso' |
|
521 | + ), |
|
522 | + '<p class="no-ticket-selector-msg clear-float">', |
|
523 | + $this->event->name(), |
|
524 | + '</p>', |
|
525 | + '<br />' |
|
526 | + ), |
|
527 | + $this->event |
|
528 | + ); |
|
529 | + if ( |
|
530 | + apply_filters( |
|
531 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
532 | + false, |
|
533 | + $this->event |
|
534 | + ) |
|
535 | + ) { |
|
536 | + $html .= $this->displayRegisterNowButton(); |
|
537 | + } |
|
538 | + // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
539 | + $html .= $this->ticketSelectorEndDiv(); |
|
540 | + } else if ( |
|
541 | + apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
542 | + && ! is_single() |
|
543 | + ) { |
|
544 | + // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
545 | + // but no tickets are available, so display event's "View Details" button. |
|
546 | + // it is being viewed via somewhere other than a single post |
|
547 | + $html .= $this->displayViewDetailsButton(true); |
|
548 | + } |
|
549 | + } else if (is_archive()) { |
|
550 | + // event list, no tickets available so display event's "View Details" button |
|
551 | + $html .= $this->ticketSelectorEndDiv(); |
|
552 | + $html .= $this->displayViewDetailsButton(); |
|
553 | + } else { |
|
554 | + if ( |
|
555 | + apply_filters( |
|
556 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
557 | + false, |
|
558 | + $this->event |
|
559 | + ) |
|
560 | + ) { |
|
561 | + $html .= $this->displayRegisterNowButton(); |
|
562 | + } |
|
563 | + // no submit or view details button, and no additional content |
|
564 | + $html .= $this->ticketSelectorEndDiv(); |
|
565 | + } |
|
566 | + if ( ! $this->iframe && ! is_archive()) { |
|
567 | + $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector')); |
|
568 | + } |
|
569 | + } |
|
570 | + return $html; |
|
571 | + } |
|
572 | + |
|
573 | + |
|
574 | + |
|
575 | + /** |
|
576 | + * @return string |
|
577 | + * @throws \EE_Error |
|
578 | + */ |
|
579 | + public function displayRegisterNowButton() |
|
580 | + { |
|
581 | + $btn_text = apply_filters( |
|
582 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
583 | + __('Register Now', 'event_espresso'), |
|
584 | + $this->event |
|
585 | + ); |
|
586 | + $external_url = $this->event->external_url(); |
|
587 | + $html = \EEH_HTML::div( |
|
588 | + '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
589 | + ); |
|
590 | + $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
591 | + $html .= ' class="ticket-selector-submit-btn '; |
|
592 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
593 | + $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
594 | + $html .= \EEH_HTML::divx(); |
|
595 | + $html .= apply_filters( |
|
596 | + 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
597 | + '', |
|
598 | + $this->event |
|
599 | + ); |
|
600 | + return $html; |
|
601 | + } |
|
602 | + |
|
603 | + |
|
604 | + /** |
|
605 | + * displayViewDetailsButton |
|
606 | + * |
|
607 | + * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
608 | + * (ie: $_max_atndz === 1) where there are no available tickets, |
|
609 | + * either because they are sold out, expired, or not yet on sale. |
|
610 | + * In this case, we need to close the form BEFORE adding any closing divs |
|
611 | + * @return string |
|
612 | + * @throws \EE_Error |
|
613 | + */ |
|
614 | + public function displayViewDetailsButton( $DWMTS = false ) |
|
615 | + { |
|
616 | + if ( ! $this->event->get_permalink() ) { |
|
617 | + \EE_Error::add_error( |
|
618 | + esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
619 | + __FILE__, __FUNCTION__, __LINE__ |
|
620 | + ); |
|
621 | + } |
|
622 | + $view_details_btn = '<form method="POST" action="'; |
|
623 | + $view_details_btn .= apply_filters( |
|
624 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
625 | + $this->event->get_permalink(), |
|
626 | + $this->event |
|
627 | + ); |
|
628 | + $view_details_btn .= '">'; |
|
629 | + $btn_text = apply_filters( |
|
630 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
631 | + esc_html__('View Details', 'event_espresso'), |
|
632 | + $this->event |
|
633 | + ); |
|
634 | + $view_details_btn .= '<input id="ticket-selector-submit-' |
|
635 | + . $this->event->ID() |
|
636 | + . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
637 | + . $btn_text |
|
638 | + . '" />'; |
|
639 | + $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
640 | + if ($DWMTS) { |
|
641 | + $view_details_btn .= $this->formClose(); |
|
642 | + $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
643 | + $view_details_btn .= '<br/>'; |
|
644 | + } else { |
|
645 | + $view_details_btn .= $this->clearTicketSelector(); |
|
646 | + $view_details_btn .= '<br/>'; |
|
647 | + $view_details_btn .= $this->formClose(); |
|
648 | + } |
|
649 | + return $view_details_btn; |
|
650 | + } |
|
651 | + |
|
652 | + |
|
653 | + |
|
654 | + /** |
|
655 | + * @return string |
|
656 | + */ |
|
657 | + public function ticketSelectorEndDiv() |
|
658 | + { |
|
659 | + return '<div class="clear"></div></div>'; |
|
660 | + } |
|
661 | + |
|
662 | + |
|
663 | + |
|
664 | + /** |
|
665 | + * @return string |
|
666 | + */ |
|
667 | + public function clearTicketSelector() |
|
668 | + { |
|
669 | + // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
670 | + return '<div class="clear"></div>'; |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + |
|
675 | + /** |
|
676 | + * @access public |
|
677 | + * @return string |
|
678 | + */ |
|
679 | + public function formClose() |
|
680 | + { |
|
681 | + return '</form>'; |
|
682 | + } |
|
683 | 683 | |
684 | 684 | |
685 | 685 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\modules\ticket_selector; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * @param boolean $iframe |
75 | 75 | */ |
76 | - public function setIframe( $iframe = true ) |
|
76 | + public function setIframe($iframe = true) |
|
77 | 77 | { |
78 | - $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
78 | + $this->iframe = filter_var($iframe, FILTER_VALIDATE_BOOLEAN); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -86,28 +86,28 @@ discard block |
||
86 | 86 | * @param mixed $event |
87 | 87 | * @return bool |
88 | 88 | */ |
89 | - protected function setEvent( $event = null ) |
|
89 | + protected function setEvent($event = null) |
|
90 | 90 | { |
91 | - if ( $event === null ) { |
|
91 | + if ($event === null) { |
|
92 | 92 | global $post; |
93 | 93 | $event = $post; |
94 | 94 | } |
95 | - if ( $event instanceof \EE_Event ) { |
|
95 | + if ($event instanceof \EE_Event) { |
|
96 | 96 | $this->event = $event; |
97 | - } else if ( $event instanceof \WP_Post ) { |
|
98 | - if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) { |
|
97 | + } else if ($event instanceof \WP_Post) { |
|
98 | + if (isset($event->EE_Event) && $event->EE_Event instanceof \EE_Event) { |
|
99 | 99 | $this->event = $event->EE_Event; |
100 | - } else if ( $event->post_type === 'espresso_events' ) { |
|
101 | - $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
100 | + } else if ($event->post_type === 'espresso_events') { |
|
101 | + $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
102 | 102 | $this->event = $event->EE_Event; |
103 | 103 | } |
104 | 104 | } else { |
105 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
106 | - $dev_msg = $user_msg . __( |
|
105 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
106 | + $dev_msg = $user_msg.__( |
|
107 | 107 | 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
108 | 108 | 'event_espresso' |
109 | 109 | ); |
110 | - \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
110 | + \EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | return true; |
@@ -148,17 +148,17 @@ discard block |
||
148 | 148 | * @return string |
149 | 149 | * @throws \EE_Error |
150 | 150 | */ |
151 | - public function display( $event = null, $view_details = false ) |
|
151 | + public function display($event = null, $view_details = false) |
|
152 | 152 | { |
153 | 153 | // reset filter for displaying submit button |
154 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
154 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
155 | 155 | // poke and prod incoming event till it tells us what it is |
156 | - if ( ! $this->setEvent( $event ) ) { |
|
156 | + if ( ! $this->setEvent($event)) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | // begin gathering template arguments by getting event status |
160 | - $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
161 | - if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
160 | + $template_args = array('event_status' => $this->event->get_active_status()); |
|
161 | + if ($this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details)) { |
|
162 | 162 | return ! is_single() ? $this->displayViewDetailsButton() : ''; |
163 | 163 | } |
164 | 164 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } |
169 | 169 | // is the event expired ? |
170 | 170 | $template_args['event_is_expired'] = $this->event->is_expired(); |
171 | - if ( $template_args[ 'event_is_expired' ] ) { |
|
171 | + if ($template_args['event_is_expired']) { |
|
172 | 172 | return $this->expiredEventMessage(); |
173 | 173 | } |
174 | 174 | // get all tickets for this event ordered by the datetime |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | // if redirecting to another site for registration, then we don't load the TS |
182 | 182 | $ticket_selector = $external_url |
183 | 183 | ? $this->externalEventRegistration() |
184 | - : $this->loadTicketSelector($tickets,$template_args); |
|
184 | + : $this->loadTicketSelector($tickets, $template_args); |
|
185 | 185 | // now set up the form (but not for the admin) |
186 | 186 | $ticket_selector = ! is_admin() |
187 | - ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
187 | + ? $this->formOpen($this->event->ID(), $external_url).$ticket_selector |
|
188 | 188 | : $ticket_selector; |
189 | 189 | // submit button and form close tag |
190 | 190 | $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | */ |
235 | 235 | protected function expiredEventMessage() |
236 | 236 | { |
237 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
237 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.esc_html__( |
|
238 | 238 | 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
239 | 239 | 'event_espresso' |
240 | - ) . '</span></div>'; |
|
240 | + ).'</span></div>'; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | protected function noTicketAvailableMessage() |
253 | 253 | { |
254 | - $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
254 | + $no_ticket_available_msg = esc_html__('We\'re sorry, but all ticket sales have ended.', 'event_espresso'); |
|
255 | 255 | if (current_user_can('edit_post', $this->event->ID())) { |
256 | 256 | $no_ticket_available_msg .= sprintf( |
257 | 257 | esc_html__( |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | } |
267 | 267 | return ' |
268 | 268 | <div class="ee-event-expired-notice"> |
269 | - <span class="important-notice">' . $no_ticket_available_msg . '</span> |
|
269 | + <span class="important-notice">' . $no_ticket_available_msg.'</span> |
|
270 | 270 | </div>'; |
271 | 271 | } |
272 | 272 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | '</a></span></div>' |
298 | 298 | ); |
299 | 299 | } |
300 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
300 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -359,12 +359,12 @@ discard block |
||
359 | 359 | */ |
360 | 360 | $template_args['anchor_id'] = apply_filters( |
361 | 361 | 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
362 | - '#tkt-slctr-tbl-' . $this->event->ID(), |
|
362 | + '#tkt-slctr-tbl-'.$this->event->ID(), |
|
363 | 363 | $this->event->ID() |
364 | 364 | ); |
365 | 365 | $template_args['tickets'] = $tickets; |
366 | 366 | $template_args['ticket_count'] = count($tickets); |
367 | - $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
367 | + $ticket_selector = $this->simpleTicketSelector($tickets, $template_args); |
|
368 | 368 | return $ticket_selector instanceof TicketSelectorSimple |
369 | 369 | ? $ticket_selector |
370 | 370 | : new TicketSelectorStandard( |
@@ -445,11 +445,11 @@ discard block |
||
445 | 445 | * @param string $external_url |
446 | 446 | * @return string |
447 | 447 | */ |
448 | - public function formOpen( $ID = 0, $external_url = '' ) |
|
448 | + public function formOpen($ID = 0, $external_url = '') |
|
449 | 449 | { |
450 | 450 | // if redirecting, we don't need any anything else |
451 | - if ( $external_url ) { |
|
452 | - $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"'; |
|
451 | + if ($external_url) { |
|
452 | + $html = '<form method="GET" action="'.\EEH_URL::refactor_url($external_url).'"'; |
|
453 | 453 | // open link in new window ? |
454 | 454 | $html .= apply_filters( |
455 | 455 | 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
@@ -458,21 +458,21 @@ discard block |
||
458 | 458 | ? ' target="_blank"' |
459 | 459 | : ''; |
460 | 460 | $html .= '>'; |
461 | - $query_args = \EEH_URL::get_query_string( $external_url ); |
|
462 | - foreach ( (array)$query_args as $query_arg => $value ) { |
|
463 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
461 | + $query_args = \EEH_URL::get_query_string($external_url); |
|
462 | + foreach ((array) $query_args as $query_arg => $value) { |
|
463 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
464 | 464 | } |
465 | 465 | return $html; |
466 | 466 | } |
467 | 467 | // if there is no submit button, then don't start building a form |
468 | 468 | // because the "View Details" button will build its own form |
469 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
469 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
470 | 470 | return ''; |
471 | 471 | } |
472 | - $checkout_url = \EEH_Event_View::event_link_url( $ID ); |
|
473 | - if ( ! $checkout_url ) { |
|
472 | + $checkout_url = \EEH_Event_View::event_link_url($ID); |
|
473 | + if ( ! $checkout_url) { |
|
474 | 474 | \EE_Error::add_error( |
475 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
475 | + esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
476 | 476 | __FILE__, |
477 | 477 | __FUNCTION__, |
478 | 478 | __LINE__ |
@@ -481,10 +481,10 @@ discard block |
||
481 | 481 | // set no cache headers and constants |
482 | 482 | \EE_System::do_not_cache(); |
483 | 483 | $extra_params = $this->iframe ? ' target="_blank"' : ''; |
484 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
485 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false ); |
|
484 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
485 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, true, false); |
|
486 | 486 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
487 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
487 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event); |
|
488 | 488 | return $html; |
489 | 489 | } |
490 | 490 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | $html .= empty($external_url) |
508 | 508 | ? $this->ticketSelectorEndDiv() |
509 | 509 | : $this->clearTicketSelector(); |
510 | - $html .= '<br/>' . $this->formClose(); |
|
510 | + $html .= '<br/>'.$this->formClose(); |
|
511 | 511 | } else if ($this->getMaxAttendees() === 1) { |
512 | 512 | // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
513 | 513 | if ($this->event->is_sold_out()) { |
@@ -585,12 +585,12 @@ discard block |
||
585 | 585 | ); |
586 | 586 | $external_url = $this->event->external_url(); |
587 | 587 | $html = \EEH_HTML::div( |
588 | - '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
588 | + '', 'ticket-selector-submit-'.$this->event->ID().'-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
589 | 589 | ); |
590 | - $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
590 | + $html .= '<input id="ticket-selector-submit-'.$this->event->ID().'-btn"'; |
|
591 | 591 | $html .= ' class="ticket-selector-submit-btn '; |
592 | 592 | $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
593 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
593 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
594 | 594 | $html .= \EEH_HTML::divx(); |
595 | 595 | $html .= apply_filters( |
596 | 596 | 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | * @return string |
612 | 612 | * @throws \EE_Error |
613 | 613 | */ |
614 | - public function displayViewDetailsButton( $DWMTS = false ) |
|
614 | + public function displayViewDetailsButton($DWMTS = false) |
|
615 | 615 | { |
616 | - if ( ! $this->event->get_permalink() ) { |
|
616 | + if ( ! $this->event->get_permalink()) { |
|
617 | 617 | \EE_Error::add_error( |
618 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
618 | + esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
619 | 619 | __FILE__, __FUNCTION__, __LINE__ |
620 | 620 | ); |
621 | 621 | } |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
637 | 637 | . $btn_text |
638 | 638 | . '" />'; |
639 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
639 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event); |
|
640 | 640 | if ($DWMTS) { |
641 | 641 | $view_details_btn .= $this->formClose(); |
642 | 642 | $view_details_btn .= $this->ticketSelectorEndDiv(); |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.3.2 |
8 | 8 | */ |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -22,729 +22,729 @@ discard block |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * constructor. |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - $this->_caf_hooks(); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
36 | - * |
|
37 | - * @since 4.3.2 |
|
38 | - * |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - private function _caf_hooks() |
|
42 | - { |
|
43 | - add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
44 | - add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
45 | - 5, 2); |
|
46 | - add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
47 | - 2); |
|
48 | - add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
49 | - 2); |
|
50 | - add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
51 | - 2); |
|
52 | - add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
53 | - add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
54 | - 2); |
|
55 | - add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
56 | - array($this, 'new_default_templates'), 5, 7); |
|
57 | - add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
58 | - 2); |
|
59 | - |
|
60 | - //shortcode parsers |
|
61 | - add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
62 | - add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
63 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
64 | - array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
65 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
66 | - array($this, 'additional_recipient_details_parser'), 5, 5); |
|
67 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
68 | - array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
69 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
70 | - array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
71 | - |
|
72 | - /** |
|
73 | - * @since 4.2.0 |
|
74 | - */ |
|
75 | - add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
76 | - add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
77 | - |
|
78 | - /** |
|
79 | - * @since 4.3.0 |
|
80 | - */ |
|
81 | - //eat our own dog food! |
|
82 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
83 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
84 | - do_action('EE_Brewing_Regular___messages_caf'); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
90 | - * messages system. |
|
91 | - * |
|
92 | - * @param array $dir_ref original array of paths |
|
93 | - * |
|
94 | - * @return array appended paths |
|
95 | - */ |
|
96 | - public function messages_autoload_paths($dir_ref) |
|
97 | - { |
|
98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
99 | - |
|
100 | - return $dir_ref; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
105 | - { |
|
106 | - $validator_config['attendee_list'] = array( |
|
107 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
108 | - 'required' => array('[ATTENDEE_LIST]') |
|
109 | - ); |
|
110 | - $validator_config['question_list'] = array( |
|
111 | - 'shortcodes' => array('question'), |
|
112 | - 'required' => array('[QUESTION_LIST]') |
|
113 | - ); |
|
114 | - |
|
115 | - return $validator_config; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
120 | - { |
|
121 | - $validator_config['attendee_list'] = array( |
|
122 | - 'shortcodes' => array('attendee', 'question_list'), |
|
123 | - 'required' => array('[ATTENDEE_LIST]') |
|
124 | - ); |
|
125 | - $validator_config['question_list'] = array( |
|
126 | - 'shortcodes' => array('question'), |
|
127 | - 'required' => array('[QUESTION_LIST]') |
|
128 | - ); |
|
129 | - |
|
130 | - return $validator_config; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
135 | - { |
|
136 | - $validator_config['attendee_list'] = array( |
|
137 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
138 | - 'required' => array('[ATTENDEE_LIST]') |
|
139 | - ); |
|
140 | - $validator_config['question_list'] = array( |
|
141 | - 'shortcodes' => array('question'), |
|
142 | - 'required' => array('[QUESTION_LIST]') |
|
143 | - ); |
|
144 | - |
|
145 | - return $validator_config; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
150 | - { |
|
151 | - $template_fields['extra']['content']['question_list'] = array( |
|
152 | - 'input' => 'textarea', |
|
153 | - 'label' => '[QUESTION_LIST]', |
|
154 | - 'type' => 'string', |
|
155 | - 'required' => true, |
|
156 | - 'validation' => true, |
|
157 | - 'format' => '%s', |
|
158 | - 'css_class' => 'large-text', |
|
159 | - 'rows' => '5', |
|
160 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
161 | - ); |
|
162 | - |
|
163 | - return $template_fields; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
168 | - { |
|
169 | - $template_fields['extra']['content']['question_list'] = array( |
|
170 | - 'input' => 'textarea', |
|
171 | - 'label' => '[QUESTION_LIST]', |
|
172 | - 'type' => 'string', |
|
173 | - 'required' => true, |
|
174 | - 'validation' => true, |
|
175 | - 'format' => '%s', |
|
176 | - 'css_class' => 'large-text', |
|
177 | - 'rows' => '5', |
|
178 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
179 | - ); |
|
180 | - |
|
181 | - return $template_fields; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
186 | - { |
|
187 | - $template_fields['extra']['content']['question_list'] = array( |
|
188 | - 'input' => 'textarea', |
|
189 | - 'label' => '[QUESTION_LIST]', |
|
190 | - 'type' => 'string', |
|
191 | - 'required' => true, |
|
192 | - 'validation' => true, |
|
193 | - 'format' => '%s', |
|
194 | - 'css_class' => 'large-text', |
|
195 | - 'rows' => '5', |
|
196 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
197 | - ); |
|
198 | - |
|
199 | - return $template_fields; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - public function new_default_templates( |
|
204 | - $contents, |
|
205 | - $actual_path, |
|
206 | - EE_messenger $messenger, |
|
207 | - EE_message_type $message_type, |
|
208 | - $field, |
|
209 | - $context, |
|
210 | - EE_Messages_Template_Pack $template_pack |
|
211 | - ) { |
|
212 | - |
|
213 | - //we're only modifying templates for the default template pack |
|
214 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
215 | - return $contents; |
|
216 | - } |
|
217 | - |
|
218 | - //the template file name we're replacing contents for. |
|
219 | - $template_file_prefix = $field . '_' . $context; |
|
220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
221 | - |
|
222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
223 | - |
|
224 | - if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
25 | + /** |
|
26 | + * constructor. |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + $this->_caf_hooks(); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
36 | + * |
|
37 | + * @since 4.3.2 |
|
38 | + * |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + private function _caf_hooks() |
|
42 | + { |
|
43 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
44 | + add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
45 | + 5, 2); |
|
46 | + add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
47 | + 2); |
|
48 | + add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
49 | + 2); |
|
50 | + add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
51 | + 2); |
|
52 | + add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
53 | + add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
54 | + 2); |
|
55 | + add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
56 | + array($this, 'new_default_templates'), 5, 7); |
|
57 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
58 | + 2); |
|
59 | + |
|
60 | + //shortcode parsers |
|
61 | + add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
62 | + add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
63 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
64 | + array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
65 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
66 | + array($this, 'additional_recipient_details_parser'), 5, 5); |
|
67 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
68 | + array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
69 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
70 | + array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
71 | + |
|
72 | + /** |
|
73 | + * @since 4.2.0 |
|
74 | + */ |
|
75 | + add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
76 | + add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
77 | + |
|
78 | + /** |
|
79 | + * @since 4.3.0 |
|
80 | + */ |
|
81 | + //eat our own dog food! |
|
82 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
83 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
84 | + do_action('EE_Brewing_Regular___messages_caf'); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
90 | + * messages system. |
|
91 | + * |
|
92 | + * @param array $dir_ref original array of paths |
|
93 | + * |
|
94 | + * @return array appended paths |
|
95 | + */ |
|
96 | + public function messages_autoload_paths($dir_ref) |
|
97 | + { |
|
98 | + $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
99 | + |
|
100 | + return $dir_ref; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
105 | + { |
|
106 | + $validator_config['attendee_list'] = array( |
|
107 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
108 | + 'required' => array('[ATTENDEE_LIST]') |
|
109 | + ); |
|
110 | + $validator_config['question_list'] = array( |
|
111 | + 'shortcodes' => array('question'), |
|
112 | + 'required' => array('[QUESTION_LIST]') |
|
113 | + ); |
|
114 | + |
|
115 | + return $validator_config; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
120 | + { |
|
121 | + $validator_config['attendee_list'] = array( |
|
122 | + 'shortcodes' => array('attendee', 'question_list'), |
|
123 | + 'required' => array('[ATTENDEE_LIST]') |
|
124 | + ); |
|
125 | + $validator_config['question_list'] = array( |
|
126 | + 'shortcodes' => array('question'), |
|
127 | + 'required' => array('[QUESTION_LIST]') |
|
128 | + ); |
|
129 | + |
|
130 | + return $validator_config; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
135 | + { |
|
136 | + $validator_config['attendee_list'] = array( |
|
137 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
138 | + 'required' => array('[ATTENDEE_LIST]') |
|
139 | + ); |
|
140 | + $validator_config['question_list'] = array( |
|
141 | + 'shortcodes' => array('question'), |
|
142 | + 'required' => array('[QUESTION_LIST]') |
|
143 | + ); |
|
144 | + |
|
145 | + return $validator_config; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
150 | + { |
|
151 | + $template_fields['extra']['content']['question_list'] = array( |
|
152 | + 'input' => 'textarea', |
|
153 | + 'label' => '[QUESTION_LIST]', |
|
154 | + 'type' => 'string', |
|
155 | + 'required' => true, |
|
156 | + 'validation' => true, |
|
157 | + 'format' => '%s', |
|
158 | + 'css_class' => 'large-text', |
|
159 | + 'rows' => '5', |
|
160 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
161 | + ); |
|
162 | + |
|
163 | + return $template_fields; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
168 | + { |
|
169 | + $template_fields['extra']['content']['question_list'] = array( |
|
170 | + 'input' => 'textarea', |
|
171 | + 'label' => '[QUESTION_LIST]', |
|
172 | + 'type' => 'string', |
|
173 | + 'required' => true, |
|
174 | + 'validation' => true, |
|
175 | + 'format' => '%s', |
|
176 | + 'css_class' => 'large-text', |
|
177 | + 'rows' => '5', |
|
178 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
179 | + ); |
|
180 | + |
|
181 | + return $template_fields; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
186 | + { |
|
187 | + $template_fields['extra']['content']['question_list'] = array( |
|
188 | + 'input' => 'textarea', |
|
189 | + 'label' => '[QUESTION_LIST]', |
|
190 | + 'type' => 'string', |
|
191 | + 'required' => true, |
|
192 | + 'validation' => true, |
|
193 | + 'format' => '%s', |
|
194 | + 'css_class' => 'large-text', |
|
195 | + 'rows' => '5', |
|
196 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
197 | + ); |
|
198 | + |
|
199 | + return $template_fields; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + public function new_default_templates( |
|
204 | + $contents, |
|
205 | + $actual_path, |
|
206 | + EE_messenger $messenger, |
|
207 | + EE_message_type $message_type, |
|
208 | + $field, |
|
209 | + $context, |
|
210 | + EE_Messages_Template_Pack $template_pack |
|
211 | + ) { |
|
212 | + |
|
213 | + //we're only modifying templates for the default template pack |
|
214 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
215 | + return $contents; |
|
216 | + } |
|
217 | + |
|
218 | + //the template file name we're replacing contents for. |
|
219 | + $template_file_prefix = $field . '_' . $context; |
|
220 | + $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
221 | + |
|
222 | + $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
223 | + |
|
224 | + if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
225 | 225 | |
226 | - switch ($template_file_prefix) { |
|
226 | + switch ($template_file_prefix) { |
|
227 | 227 | |
228 | - case 'question_list_admin' : |
|
229 | - case 'question_list_attendee' : |
|
230 | - case 'question_list_primary_attendee' : |
|
231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
232 | - $contents = EEH_Template::display_template($path, array(), true); |
|
233 | - break; |
|
228 | + case 'question_list_admin' : |
|
229 | + case 'question_list_attendee' : |
|
230 | + case 'question_list_primary_attendee' : |
|
231 | + $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
232 | + $contents = EEH_Template::display_template($path, array(), true); |
|
233 | + break; |
|
234 | 234 | |
235 | - case 'attendee_list_primary_attendee' : |
|
236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
237 | - $contents = EEH_Template::display_template($path, array(), true); |
|
238 | - break; |
|
235 | + case 'attendee_list_primary_attendee' : |
|
236 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
237 | + $contents = EEH_Template::display_template($path, array(), true); |
|
238 | + break; |
|
239 | 239 | |
240 | - case 'attendee_list_admin' : |
|
241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
242 | - $contents = EEH_Template::display_template($path, |
|
243 | - array(), true); |
|
244 | - break; |
|
240 | + case 'attendee_list_admin' : |
|
241 | + $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
242 | + $contents = EEH_Template::display_template($path, |
|
243 | + array(), true); |
|
244 | + break; |
|
245 | 245 | |
246 | - case 'attendee_list_attendee' : |
|
247 | - $contents = ''; |
|
248 | - break; |
|
246 | + case 'attendee_list_attendee' : |
|
247 | + $contents = ''; |
|
248 | + break; |
|
249 | 249 | |
250 | - case 'event_list_attendee' : |
|
251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
252 | - $contents = EEH_Template::display_template($path, array(), true); |
|
253 | - break; |
|
254 | - } |
|
255 | - } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
256 | - switch ($template_file_prefix) { |
|
250 | + case 'event_list_attendee' : |
|
251 | + $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
252 | + $contents = EEH_Template::display_template($path, array(), true); |
|
253 | + break; |
|
254 | + } |
|
255 | + } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
256 | + switch ($template_file_prefix) { |
|
257 | 257 | |
258 | - case 'content_attendee' : |
|
259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
260 | - $contents = EEH_Template::display_template($path, array(), true); |
|
261 | - break; |
|
258 | + case 'content_attendee' : |
|
259 | + $path = $base_path . $msg_prefix . 'content.template.php'; |
|
260 | + $contents = EEH_Template::display_template($path, array(), true); |
|
261 | + break; |
|
262 | 262 | |
263 | - case 'newsletter_content_attendee' : |
|
264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
265 | - $contents = EEH_Template::display_template($path, array(), true); |
|
266 | - break; |
|
263 | + case 'newsletter_content_attendee' : |
|
264 | + $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
265 | + $contents = EEH_Template::display_template($path, array(), true); |
|
266 | + break; |
|
267 | 267 | |
268 | - case 'newsletter_subject_attendee' : |
|
269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
270 | - $contents = EEH_Template::display_template($path, array(), true); |
|
271 | - break; |
|
272 | - } |
|
273 | - } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
274 | - switch ($template_file_prefix) { |
|
275 | - case 'attendee_list_purchaser' : |
|
276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
277 | - $contents = EEH_Template::display_template($path, array(), true); |
|
278 | - break; |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - return $contents; |
|
283 | - |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
288 | - { |
|
289 | - //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
290 | - $include_with = array( |
|
291 | - 'registration', |
|
292 | - 'cancelled_registration', |
|
293 | - 'declined_registration', |
|
294 | - 'not_approved_registration', |
|
295 | - 'payment_declined', |
|
296 | - 'payment_failed', |
|
297 | - 'payment_cancelled', |
|
298 | - 'payment', |
|
299 | - 'payment_reminder', |
|
300 | - 'pending_approval', |
|
301 | - 'registration_summary', |
|
302 | - 'invoice', |
|
303 | - 'receipt' |
|
304 | - ); |
|
305 | - if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
306 | - $contexts = array_keys($msg->get_contexts()); |
|
307 | - foreach ($contexts as $context) { |
|
308 | - $valid_shortcodes[$context][] = 'question_list'; |
|
309 | - $valid_shortcodes[$context][] = 'question'; |
|
310 | - } |
|
311 | - } |
|
312 | - |
|
313 | - return $valid_shortcodes; |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
318 | - { |
|
319 | - $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
320 | - 'event_espresso'); |
|
321 | - |
|
322 | - return $shortcodes; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
327 | - { |
|
328 | - |
|
329 | - if (strpos($shortcode, |
|
330 | - '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
331 | - ) { |
|
332 | - return $parsed; |
|
333 | - } |
|
334 | - |
|
335 | - //let's get the question from the code. |
|
336 | - $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
337 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
338 | - |
|
339 | - $registration = $data instanceof EE_Registration ? $data : null; |
|
340 | - $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
341 | - |
|
342 | - $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
343 | - $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
344 | - |
|
345 | - if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
346 | - return $parsed; |
|
347 | - } |
|
348 | - |
|
349 | - //now let's figure out which question has this text. |
|
350 | - foreach ($aee->questions as $ansid => $question) { |
|
351 | - if ( |
|
352 | - $question instanceof EE_Question |
|
353 | - && trim($question->display_text()) == trim($shortcode) |
|
354 | - && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
355 | - ) { |
|
356 | - return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
357 | - 'no_wpautop'); |
|
358 | - } |
|
359 | - } |
|
360 | - |
|
361 | - //nothing! |
|
362 | - return $parsed; |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - /** |
|
367 | - * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
368 | - * |
|
369 | - * @since 4.2 |
|
370 | - * |
|
371 | - * @param array $shortcodes array of shortcodes and |
|
372 | - * descriptions |
|
373 | - * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
374 | - * |
|
375 | - * @return array array of shortcodes and |
|
376 | - * descriptions |
|
377 | - */ |
|
378 | - public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
379 | - { |
|
380 | - $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
381 | - 'event_espresso'); |
|
382 | - $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
383 | - 'event_espresso'); |
|
384 | - $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
385 | - 'event_espresso'); |
|
386 | - |
|
387 | - return $shortcodes; |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * Callback for additional shortcodes parser filter used for adding parser for new |
|
393 | - * Datetime shortcodes |
|
394 | - * |
|
395 | - * @since 4.2 |
|
396 | - * |
|
397 | - * @param string $parsed The finished parsed string for the given shortcode. |
|
398 | - * @param string $shortcode The shortcode being parsed. |
|
399 | - * @param object $data The incoming data object for the Shortcode Parser. |
|
400 | - * @param object $extra_data The incoming extra date object for the Shortcode |
|
401 | - * Parser. |
|
402 | - * @param EE_Datetime_Shortcodes $shortcode_parser |
|
403 | - * |
|
404 | - * @return string The new parsed string. |
|
405 | - */ |
|
406 | - public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
407 | - { |
|
408 | - |
|
409 | - if ( ! $data instanceof EE_Datetime) { |
|
410 | - return ''; //get out because we can only parse with the datetime object. |
|
411 | - } |
|
412 | - |
|
413 | - switch ($shortcode) { |
|
414 | - case '[DTT_NAME]' : |
|
415 | - return $data->name(); |
|
416 | - break; |
|
417 | - case '[DTT_DESCRIPTION]' : |
|
418 | - return $data->description(); |
|
419 | - break; |
|
420 | - case '[DTT_NAME_OR_DATES]' : |
|
421 | - return $data->get_dtt_display_name(true); |
|
422 | - break; |
|
423 | - default : |
|
424 | - return $parsed; |
|
425 | - break; |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
431 | - { |
|
432 | - $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
433 | - 'event_espresso'); |
|
434 | - |
|
435 | - return $shortcodes; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
441 | - * |
|
442 | - * @param string $parsed The original parsed content for the shortcode |
|
443 | - * @param string $shortcode The shortcode being parsed |
|
444 | - * @param array $data The shortcode parser data array |
|
445 | - * @param array $extra_data The shortcode parser extra data array |
|
446 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
447 | - * |
|
448 | - * @return string |
|
449 | - */ |
|
450 | - public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
451 | - { |
|
452 | - |
|
453 | - if (array($data) && ! isset($data['data'])) { |
|
454 | - return $parsed; |
|
455 | - } |
|
456 | - |
|
457 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
458 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
459 | - |
|
460 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
461 | - return $parsed; |
|
462 | - } |
|
463 | - |
|
464 | - switch ($shortcode) { |
|
465 | - case '[RECIPIENT_QUESTION_LIST]' : |
|
466 | - $att = $recipient->att_obj; |
|
467 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
468 | - $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
469 | - $answers = array(); |
|
268 | + case 'newsletter_subject_attendee' : |
|
269 | + $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
270 | + $contents = EEH_Template::display_template($path, array(), true); |
|
271 | + break; |
|
272 | + } |
|
273 | + } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
274 | + switch ($template_file_prefix) { |
|
275 | + case 'attendee_list_purchaser' : |
|
276 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
277 | + $contents = EEH_Template::display_template($path, array(), true); |
|
278 | + break; |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + return $contents; |
|
283 | + |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
288 | + { |
|
289 | + //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
290 | + $include_with = array( |
|
291 | + 'registration', |
|
292 | + 'cancelled_registration', |
|
293 | + 'declined_registration', |
|
294 | + 'not_approved_registration', |
|
295 | + 'payment_declined', |
|
296 | + 'payment_failed', |
|
297 | + 'payment_cancelled', |
|
298 | + 'payment', |
|
299 | + 'payment_reminder', |
|
300 | + 'pending_approval', |
|
301 | + 'registration_summary', |
|
302 | + 'invoice', |
|
303 | + 'receipt' |
|
304 | + ); |
|
305 | + if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
306 | + $contexts = array_keys($msg->get_contexts()); |
|
307 | + foreach ($contexts as $context) { |
|
308 | + $valid_shortcodes[$context][] = 'question_list'; |
|
309 | + $valid_shortcodes[$context][] = 'question'; |
|
310 | + } |
|
311 | + } |
|
312 | + |
|
313 | + return $valid_shortcodes; |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
318 | + { |
|
319 | + $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
320 | + 'event_espresso'); |
|
321 | + |
|
322 | + return $shortcodes; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
327 | + { |
|
328 | + |
|
329 | + if (strpos($shortcode, |
|
330 | + '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
331 | + ) { |
|
332 | + return $parsed; |
|
333 | + } |
|
334 | + |
|
335 | + //let's get the question from the code. |
|
336 | + $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
337 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
338 | + |
|
339 | + $registration = $data instanceof EE_Registration ? $data : null; |
|
340 | + $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
341 | + |
|
342 | + $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
343 | + $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
344 | + |
|
345 | + if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
346 | + return $parsed; |
|
347 | + } |
|
348 | + |
|
349 | + //now let's figure out which question has this text. |
|
350 | + foreach ($aee->questions as $ansid => $question) { |
|
351 | + if ( |
|
352 | + $question instanceof EE_Question |
|
353 | + && trim($question->display_text()) == trim($shortcode) |
|
354 | + && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
355 | + ) { |
|
356 | + return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
357 | + 'no_wpautop'); |
|
358 | + } |
|
359 | + } |
|
360 | + |
|
361 | + //nothing! |
|
362 | + return $parsed; |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + /** |
|
367 | + * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
368 | + * |
|
369 | + * @since 4.2 |
|
370 | + * |
|
371 | + * @param array $shortcodes array of shortcodes and |
|
372 | + * descriptions |
|
373 | + * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
374 | + * |
|
375 | + * @return array array of shortcodes and |
|
376 | + * descriptions |
|
377 | + */ |
|
378 | + public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
379 | + { |
|
380 | + $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
381 | + 'event_espresso'); |
|
382 | + $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
383 | + 'event_espresso'); |
|
384 | + $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
385 | + 'event_espresso'); |
|
386 | + |
|
387 | + return $shortcodes; |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * Callback for additional shortcodes parser filter used for adding parser for new |
|
393 | + * Datetime shortcodes |
|
394 | + * |
|
395 | + * @since 4.2 |
|
396 | + * |
|
397 | + * @param string $parsed The finished parsed string for the given shortcode. |
|
398 | + * @param string $shortcode The shortcode being parsed. |
|
399 | + * @param object $data The incoming data object for the Shortcode Parser. |
|
400 | + * @param object $extra_data The incoming extra date object for the Shortcode |
|
401 | + * Parser. |
|
402 | + * @param EE_Datetime_Shortcodes $shortcode_parser |
|
403 | + * |
|
404 | + * @return string The new parsed string. |
|
405 | + */ |
|
406 | + public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
407 | + { |
|
408 | + |
|
409 | + if ( ! $data instanceof EE_Datetime) { |
|
410 | + return ''; //get out because we can only parse with the datetime object. |
|
411 | + } |
|
412 | + |
|
413 | + switch ($shortcode) { |
|
414 | + case '[DTT_NAME]' : |
|
415 | + return $data->name(); |
|
416 | + break; |
|
417 | + case '[DTT_DESCRIPTION]' : |
|
418 | + return $data->description(); |
|
419 | + break; |
|
420 | + case '[DTT_NAME_OR_DATES]' : |
|
421 | + return $data->get_dtt_display_name(true); |
|
422 | + break; |
|
423 | + default : |
|
424 | + return $parsed; |
|
425 | + break; |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
431 | + { |
|
432 | + $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
433 | + 'event_espresso'); |
|
434 | + |
|
435 | + return $shortcodes; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
441 | + * |
|
442 | + * @param string $parsed The original parsed content for the shortcode |
|
443 | + * @param string $shortcode The shortcode being parsed |
|
444 | + * @param array $data The shortcode parser data array |
|
445 | + * @param array $extra_data The shortcode parser extra data array |
|
446 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
447 | + * |
|
448 | + * @return string |
|
449 | + */ |
|
450 | + public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
451 | + { |
|
452 | + |
|
453 | + if (array($data) && ! isset($data['data'])) { |
|
454 | + return $parsed; |
|
455 | + } |
|
456 | + |
|
457 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
458 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
459 | + |
|
460 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
461 | + return $parsed; |
|
462 | + } |
|
463 | + |
|
464 | + switch ($shortcode) { |
|
465 | + case '[RECIPIENT_QUESTION_LIST]' : |
|
466 | + $att = $recipient->att_obj; |
|
467 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
468 | + $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
469 | + $answers = array(); |
|
470 | 470 | |
471 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
472 | - $valid_shortcodes = array('question'); |
|
471 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
472 | + $valid_shortcodes = array('question'); |
|
473 | 473 | |
474 | - //if the context is main_content then get all answers for all registrations on this attendee |
|
475 | - if ($data['data'] instanceof EE_Messages_Addressee) { |
|
474 | + //if the context is main_content then get all answers for all registrations on this attendee |
|
475 | + if ($data['data'] instanceof EE_Messages_Addressee) { |
|
476 | 476 | |
477 | - foreach ($registrations_on_attendee as $reg) { |
|
478 | - if ($reg instanceof EE_Registration) { |
|
479 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
480 | - foreach ($anss as $ans) { |
|
481 | - if ($ans instanceof EE_Answer) { |
|
482 | - $answers[$ans->ID()] = $ans; |
|
483 | - } |
|
484 | - } |
|
485 | - } |
|
486 | - } |
|
487 | - } |
|
477 | + foreach ($registrations_on_attendee as $reg) { |
|
478 | + if ($reg instanceof EE_Registration) { |
|
479 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
480 | + foreach ($anss as $ans) { |
|
481 | + if ($ans instanceof EE_Answer) { |
|
482 | + $answers[$ans->ID()] = $ans; |
|
483 | + } |
|
484 | + } |
|
485 | + } |
|
486 | + } |
|
487 | + } |
|
488 | 488 | |
489 | - //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
490 | - if ($data['data'] instanceof EE_Event) { |
|
491 | - $event = $data['data']; |
|
492 | - foreach ($registrations_on_attendee as $reg) { |
|
493 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
494 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
495 | - foreach ($anss as $ans) { |
|
496 | - if ($ans instanceof EE_Answer) { |
|
497 | - $answers[$ans->ID()] = $ans; |
|
498 | - } |
|
499 | - } |
|
500 | - } |
|
501 | - } |
|
502 | - } |
|
489 | + //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
490 | + if ($data['data'] instanceof EE_Event) { |
|
491 | + $event = $data['data']; |
|
492 | + foreach ($registrations_on_attendee as $reg) { |
|
493 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
494 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
495 | + foreach ($anss as $ans) { |
|
496 | + if ($ans instanceof EE_Answer) { |
|
497 | + $answers[$ans->ID()] = $ans; |
|
498 | + } |
|
499 | + } |
|
500 | + } |
|
501 | + } |
|
502 | + } |
|
503 | 503 | |
504 | - $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
504 | + $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
505 | 505 | |
506 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
507 | - //object on it. |
|
508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
509 | - $extra_data['data'] = $recipient; |
|
510 | - } |
|
506 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
507 | + //object on it. |
|
508 | + if ( ! isset( $extra_data['data'] ) ) { |
|
509 | + $extra_data['data'] = $recipient; |
|
510 | + } |
|
511 | 511 | |
512 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
513 | - $shortcode_parser, |
|
514 | - $questions, |
|
515 | - $answers, |
|
516 | - $template, |
|
517 | - $valid_shortcodes, |
|
518 | - $extra_data |
|
519 | - ); |
|
520 | - break; |
|
512 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
513 | + $shortcode_parser, |
|
514 | + $questions, |
|
515 | + $answers, |
|
516 | + $template, |
|
517 | + $valid_shortcodes, |
|
518 | + $extra_data |
|
519 | + ); |
|
520 | + break; |
|
521 | 521 | |
522 | - default : |
|
523 | - return $parsed; |
|
524 | - break; |
|
525 | - } |
|
526 | - } |
|
527 | - |
|
528 | - |
|
529 | - public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
530 | - { |
|
531 | - $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
532 | - 'event_espresso'); |
|
533 | - |
|
534 | - return $shortcodes; |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - /** |
|
539 | - * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
540 | - * |
|
541 | - * @param string $parsed The original parsed content for the shortcode |
|
542 | - * @param string $shortcode The shortcode being parsed |
|
543 | - * @param array $data The shortcode parser data array |
|
544 | - * @param array $extra_data The shortcode parser extra data array |
|
545 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
546 | - * |
|
547 | - * @return string |
|
548 | - */ |
|
549 | - public function additional_primary_registration_details_parser( |
|
550 | - $parsed, |
|
551 | - $shortcode, |
|
552 | - $data, |
|
553 | - $extra_data, |
|
554 | - $shortcode_parser |
|
555 | - ) { |
|
556 | - if (array($data) && ! isset($data['data'])) { |
|
557 | - return $parsed; |
|
558 | - } |
|
559 | - |
|
560 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
561 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
562 | - |
|
563 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
564 | - return $parsed; |
|
565 | - } |
|
566 | - |
|
567 | - switch ($shortcode) { |
|
568 | - case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
569 | - if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
570 | - return ''; |
|
571 | - } |
|
572 | - $registration = $recipient->primary_reg_obj; |
|
573 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
574 | - $valid_shortcodes = array('question'); |
|
575 | - $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
576 | - $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
577 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
578 | - //object on it. |
|
579 | - if ( ! isset( $extra_data['data'] ) ){ |
|
580 | - $extra_data['data'] = $recipient; |
|
581 | - } |
|
582 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
583 | - $shortcode_parser, |
|
584 | - $questions, |
|
585 | - $answers, |
|
586 | - $template, |
|
587 | - $valid_shortcodes, |
|
588 | - $extra_data |
|
589 | - ); |
|
590 | - break; |
|
522 | + default : |
|
523 | + return $parsed; |
|
524 | + break; |
|
525 | + } |
|
526 | + } |
|
527 | + |
|
528 | + |
|
529 | + public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
530 | + { |
|
531 | + $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
532 | + 'event_espresso'); |
|
533 | + |
|
534 | + return $shortcodes; |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + /** |
|
539 | + * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
540 | + * |
|
541 | + * @param string $parsed The original parsed content for the shortcode |
|
542 | + * @param string $shortcode The shortcode being parsed |
|
543 | + * @param array $data The shortcode parser data array |
|
544 | + * @param array $extra_data The shortcode parser extra data array |
|
545 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
546 | + * |
|
547 | + * @return string |
|
548 | + */ |
|
549 | + public function additional_primary_registration_details_parser( |
|
550 | + $parsed, |
|
551 | + $shortcode, |
|
552 | + $data, |
|
553 | + $extra_data, |
|
554 | + $shortcode_parser |
|
555 | + ) { |
|
556 | + if (array($data) && ! isset($data['data'])) { |
|
557 | + return $parsed; |
|
558 | + } |
|
559 | + |
|
560 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
561 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
562 | + |
|
563 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
564 | + return $parsed; |
|
565 | + } |
|
566 | + |
|
567 | + switch ($shortcode) { |
|
568 | + case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
569 | + if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
570 | + return ''; |
|
571 | + } |
|
572 | + $registration = $recipient->primary_reg_obj; |
|
573 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
574 | + $valid_shortcodes = array('question'); |
|
575 | + $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
576 | + $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
577 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
578 | + //object on it. |
|
579 | + if ( ! isset( $extra_data['data'] ) ){ |
|
580 | + $extra_data['data'] = $recipient; |
|
581 | + } |
|
582 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
583 | + $shortcode_parser, |
|
584 | + $questions, |
|
585 | + $answers, |
|
586 | + $template, |
|
587 | + $valid_shortcodes, |
|
588 | + $extra_data |
|
589 | + ); |
|
590 | + break; |
|
591 | 591 | |
592 | - default : |
|
593 | - return $parsed; |
|
594 | - break; |
|
595 | - } |
|
596 | - } |
|
597 | - |
|
598 | - |
|
599 | - /** |
|
600 | - * Takes care of registering the message types that are only available in caffeinated EE. |
|
601 | - * |
|
602 | - * @since 4.3.2 |
|
603 | - * |
|
604 | - * @return void |
|
605 | - */ |
|
606 | - public function register_caf_message_types() |
|
607 | - { |
|
608 | - //register newsletter message type |
|
609 | - $setup_args = array( |
|
610 | - 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
611 | - 'autoloadpaths' => array( |
|
612 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
613 | - ), |
|
614 | - 'messengers_to_activate_with' => array('email'), |
|
615 | - 'messengers_to_validate_with' => array('email'), |
|
616 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
617 | - ); |
|
618 | - EE_Register_Message_Type::register('newsletter', $setup_args); |
|
619 | - |
|
620 | - //register payment reminder message type |
|
621 | - $setup_args = array( |
|
622 | - 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
623 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
624 | - 'messengers_to_activate_with' => array('email'), |
|
625 | - 'messengers_to_validate_with' => array('email'), |
|
626 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
627 | - ); |
|
628 | - EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
629 | - |
|
630 | - //register payment declined message type |
|
631 | - $setup_args = array( |
|
632 | - 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
633 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
634 | - 'messengers_to_activate_with' => array('email'), |
|
635 | - 'messengers_to_validate_with' => array('email'), |
|
636 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
637 | - ); |
|
638 | - EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
639 | - |
|
640 | - //register registration declined message type |
|
641 | - $setup_args = array( |
|
642 | - 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
643 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
644 | - 'messengers_to_activate_with' => array('email'), |
|
645 | - 'messengers_to_validate_with' => array('email'), |
|
646 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
647 | - ); |
|
648 | - EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
649 | - |
|
650 | - //register registration cancelled message type |
|
651 | - $setup_args = array( |
|
652 | - 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
653 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
654 | - 'messengers_to_activate_with' => array('email'), |
|
655 | - 'messengers_to_validate_with' => array('email'), |
|
656 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
657 | - ); |
|
658 | - EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
659 | - |
|
660 | - |
|
661 | - //register payment failed message type |
|
662 | - $setup_args = array( |
|
663 | - 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
664 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
665 | - 'messengers_to_activate_with' => array('email'), |
|
666 | - 'messengers_to_validate_with' => array('email'), |
|
667 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
668 | - ); |
|
669 | - EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
670 | - |
|
671 | - //register payment declined message type |
|
672 | - $setup_args = array( |
|
673 | - 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
674 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
675 | - 'messengers_to_activate_with' => array('email'), |
|
676 | - 'messengers_to_validate_with' => array('email'), |
|
677 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
678 | - ); |
|
679 | - EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
680 | - } |
|
681 | - |
|
682 | - |
|
683 | - /** |
|
684 | - * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
685 | - * |
|
686 | - * @since 4.3.2 |
|
687 | - * |
|
688 | - * @return void |
|
689 | - */ |
|
690 | - public function register_caf_shortcodes() |
|
691 | - { |
|
692 | - $setup_args = array( |
|
693 | - 'autoloadpaths' => array( |
|
694 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
695 | - ), |
|
696 | - 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
697 | - 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
698 | - 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
699 | - ); |
|
700 | - EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
701 | - } |
|
702 | - |
|
703 | - |
|
704 | - /** |
|
705 | - * Parses a question list shortcode using given data and template |
|
706 | - * |
|
707 | - * @param \EE_Shortcodes $shortcode_parser |
|
708 | - * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
709 | - * @param EE_Answer[] $answers An array of answer objects |
|
710 | - * @param string $template Template content to be parsed. |
|
711 | - * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
712 | - * @param array $extra_data Extra data that might be used when parsing the template. |
|
713 | - */ |
|
714 | - protected function _parse_question_list_for_primary_or_recipient_registration( |
|
715 | - $shortcode_parser, |
|
716 | - $questions, |
|
717 | - $answers, |
|
718 | - $template, |
|
719 | - $valid_shortcodes, |
|
720 | - $extra_data |
|
721 | - ) { |
|
722 | - $question_list = ''; |
|
723 | - /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
724 | - $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
725 | - foreach ($answers as $answer) { |
|
726 | - if ($answer instanceof EE_Answer) { |
|
727 | - //first see if the question is in our $questions array. If not then try to get from answer object. |
|
728 | - $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
729 | - $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
730 | - if ( |
|
731 | - ! $question instanceof EE_Question |
|
732 | - || ( |
|
733 | - $question instanceof EE_Question |
|
734 | - && $question->admin_only() |
|
735 | - ) |
|
736 | - ) { |
|
737 | - continue; |
|
738 | - } |
|
739 | - $question_list .= $shortcode_helper->parse_question_list_template( |
|
740 | - $template, |
|
741 | - $answer, |
|
742 | - $valid_shortcodes, |
|
743 | - $extra_data |
|
744 | - ); |
|
745 | - } |
|
746 | - } |
|
747 | - |
|
748 | - return $question_list; |
|
749 | - } |
|
592 | + default : |
|
593 | + return $parsed; |
|
594 | + break; |
|
595 | + } |
|
596 | + } |
|
597 | + |
|
598 | + |
|
599 | + /** |
|
600 | + * Takes care of registering the message types that are only available in caffeinated EE. |
|
601 | + * |
|
602 | + * @since 4.3.2 |
|
603 | + * |
|
604 | + * @return void |
|
605 | + */ |
|
606 | + public function register_caf_message_types() |
|
607 | + { |
|
608 | + //register newsletter message type |
|
609 | + $setup_args = array( |
|
610 | + 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
611 | + 'autoloadpaths' => array( |
|
612 | + EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
613 | + ), |
|
614 | + 'messengers_to_activate_with' => array('email'), |
|
615 | + 'messengers_to_validate_with' => array('email'), |
|
616 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
617 | + ); |
|
618 | + EE_Register_Message_Type::register('newsletter', $setup_args); |
|
619 | + |
|
620 | + //register payment reminder message type |
|
621 | + $setup_args = array( |
|
622 | + 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
623 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
624 | + 'messengers_to_activate_with' => array('email'), |
|
625 | + 'messengers_to_validate_with' => array('email'), |
|
626 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
627 | + ); |
|
628 | + EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
629 | + |
|
630 | + //register payment declined message type |
|
631 | + $setup_args = array( |
|
632 | + 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
633 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
634 | + 'messengers_to_activate_with' => array('email'), |
|
635 | + 'messengers_to_validate_with' => array('email'), |
|
636 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
637 | + ); |
|
638 | + EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
639 | + |
|
640 | + //register registration declined message type |
|
641 | + $setup_args = array( |
|
642 | + 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
643 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
644 | + 'messengers_to_activate_with' => array('email'), |
|
645 | + 'messengers_to_validate_with' => array('email'), |
|
646 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
647 | + ); |
|
648 | + EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
649 | + |
|
650 | + //register registration cancelled message type |
|
651 | + $setup_args = array( |
|
652 | + 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
653 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
654 | + 'messengers_to_activate_with' => array('email'), |
|
655 | + 'messengers_to_validate_with' => array('email'), |
|
656 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
657 | + ); |
|
658 | + EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
659 | + |
|
660 | + |
|
661 | + //register payment failed message type |
|
662 | + $setup_args = array( |
|
663 | + 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
664 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
665 | + 'messengers_to_activate_with' => array('email'), |
|
666 | + 'messengers_to_validate_with' => array('email'), |
|
667 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
668 | + ); |
|
669 | + EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
670 | + |
|
671 | + //register payment declined message type |
|
672 | + $setup_args = array( |
|
673 | + 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
674 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
675 | + 'messengers_to_activate_with' => array('email'), |
|
676 | + 'messengers_to_validate_with' => array('email'), |
|
677 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
678 | + ); |
|
679 | + EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
680 | + } |
|
681 | + |
|
682 | + |
|
683 | + /** |
|
684 | + * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
685 | + * |
|
686 | + * @since 4.3.2 |
|
687 | + * |
|
688 | + * @return void |
|
689 | + */ |
|
690 | + public function register_caf_shortcodes() |
|
691 | + { |
|
692 | + $setup_args = array( |
|
693 | + 'autoloadpaths' => array( |
|
694 | + EE_CAF_LIBRARIES . 'shortcodes/' |
|
695 | + ), |
|
696 | + 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
697 | + 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
698 | + 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
699 | + ); |
|
700 | + EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
701 | + } |
|
702 | + |
|
703 | + |
|
704 | + /** |
|
705 | + * Parses a question list shortcode using given data and template |
|
706 | + * |
|
707 | + * @param \EE_Shortcodes $shortcode_parser |
|
708 | + * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
709 | + * @param EE_Answer[] $answers An array of answer objects |
|
710 | + * @param string $template Template content to be parsed. |
|
711 | + * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
712 | + * @param array $extra_data Extra data that might be used when parsing the template. |
|
713 | + */ |
|
714 | + protected function _parse_question_list_for_primary_or_recipient_registration( |
|
715 | + $shortcode_parser, |
|
716 | + $questions, |
|
717 | + $answers, |
|
718 | + $template, |
|
719 | + $valid_shortcodes, |
|
720 | + $extra_data |
|
721 | + ) { |
|
722 | + $question_list = ''; |
|
723 | + /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
724 | + $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
725 | + foreach ($answers as $answer) { |
|
726 | + if ($answer instanceof EE_Answer) { |
|
727 | + //first see if the question is in our $questions array. If not then try to get from answer object. |
|
728 | + $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
729 | + $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
730 | + if ( |
|
731 | + ! $question instanceof EE_Question |
|
732 | + || ( |
|
733 | + $question instanceof EE_Question |
|
734 | + && $question->admin_only() |
|
735 | + ) |
|
736 | + ) { |
|
737 | + continue; |
|
738 | + } |
|
739 | + $question_list .= $shortcode_helper->parse_question_list_template( |
|
740 | + $template, |
|
741 | + $answer, |
|
742 | + $valid_shortcodes, |
|
743 | + $extra_data |
|
744 | + ); |
|
745 | + } |
|
746 | + } |
|
747 | + |
|
748 | + return $question_list; |
|
749 | + } |
|
750 | 750 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function messages_autoload_paths($dir_ref) |
97 | 97 | { |
98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
98 | + $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/'; |
|
99 | 99 | |
100 | 100 | return $dir_ref; |
101 | 101 | } |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | //the template file name we're replacing contents for. |
219 | - $template_file_prefix = $field . '_' . $context; |
|
220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
219 | + $template_file_prefix = $field.'_'.$context; |
|
220 | + $msg_prefix = $messenger->name.'_'.$message_type->name.'_'; |
|
221 | 221 | |
222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
222 | + $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/'; |
|
223 | 223 | |
224 | 224 | if ($messenger->name == 'email' && $message_type->name == 'registration') { |
225 | 225 | |
@@ -228,17 +228,17 @@ discard block |
||
228 | 228 | case 'question_list_admin' : |
229 | 229 | case 'question_list_attendee' : |
230 | 230 | case 'question_list_primary_attendee' : |
231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
231 | + $path = $base_path.$msg_prefix.'question_list.template.php'; |
|
232 | 232 | $contents = EEH_Template::display_template($path, array(), true); |
233 | 233 | break; |
234 | 234 | |
235 | 235 | case 'attendee_list_primary_attendee' : |
236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
236 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
237 | 237 | $contents = EEH_Template::display_template($path, array(), true); |
238 | 238 | break; |
239 | 239 | |
240 | 240 | case 'attendee_list_admin' : |
241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
241 | + $path = $base_path.$msg_prefix.'attendee_list_admin.template.php'; |
|
242 | 242 | $contents = EEH_Template::display_template($path, |
243 | 243 | array(), true); |
244 | 244 | break; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'event_list_attendee' : |
251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
251 | + $path = $base_path.$msg_prefix.'event_list_attendee.template.php'; |
|
252 | 252 | $contents = EEH_Template::display_template($path, array(), true); |
253 | 253 | break; |
254 | 254 | } |
@@ -256,24 +256,24 @@ discard block |
||
256 | 256 | switch ($template_file_prefix) { |
257 | 257 | |
258 | 258 | case 'content_attendee' : |
259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
259 | + $path = $base_path.$msg_prefix.'content.template.php'; |
|
260 | 260 | $contents = EEH_Template::display_template($path, array(), true); |
261 | 261 | break; |
262 | 262 | |
263 | 263 | case 'newsletter_content_attendee' : |
264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
264 | + $path = $base_path.$msg_prefix.'newsletter_content.template.php'; |
|
265 | 265 | $contents = EEH_Template::display_template($path, array(), true); |
266 | 266 | break; |
267 | 267 | |
268 | 268 | case 'newsletter_subject_attendee' : |
269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
269 | + $path = $base_path.$msg_prefix.'subject.template.php'; |
|
270 | 270 | $contents = EEH_Template::display_template($path, array(), true); |
271 | 271 | break; |
272 | 272 | } |
273 | 273 | } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
274 | 274 | switch ($template_file_prefix) { |
275 | 275 | case 'attendee_list_purchaser' : |
276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
276 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
277 | 277 | $contents = EEH_Template::display_template($path, array(), true); |
278 | 278 | break; |
279 | 279 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
507 | 507 | //object on it. |
508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
508 | + if ( ! isset($extra_data['data'])) { |
|
509 | 509 | $extra_data['data'] = $recipient; |
510 | 510 | } |
511 | 511 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $questions = isset($recipient->questions) ? $recipient->questions : array(); |
577 | 577 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
578 | 578 | //object on it. |
579 | - if ( ! isset( $extra_data['data'] ) ){ |
|
579 | + if ( ! isset($extra_data['data'])) { |
|
580 | 580 | $extra_data['data'] = $recipient; |
581 | 581 | } |
582 | 582 | return $this->_parse_question_list_for_primary_or_recipient_registration( |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | $setup_args = array( |
610 | 610 | 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
611 | 611 | 'autoloadpaths' => array( |
612 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
612 | + EE_CAF_LIBRARIES.'messages/message_type/newsletter/' |
|
613 | 613 | ), |
614 | 614 | 'messengers_to_activate_with' => array('email'), |
615 | 615 | 'messengers_to_validate_with' => array('email'), |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | //register payment reminder message type |
621 | 621 | $setup_args = array( |
622 | 622 | 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
623 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
623 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'), |
|
624 | 624 | 'messengers_to_activate_with' => array('email'), |
625 | 625 | 'messengers_to_validate_with' => array('email'), |
626 | 626 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | //register payment declined message type |
631 | 631 | $setup_args = array( |
632 | 632 | 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
633 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
633 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'), |
|
634 | 634 | 'messengers_to_activate_with' => array('email'), |
635 | 635 | 'messengers_to_validate_with' => array('email'), |
636 | 636 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | //register registration declined message type |
641 | 641 | $setup_args = array( |
642 | 642 | 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
643 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
643 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'), |
|
644 | 644 | 'messengers_to_activate_with' => array('email'), |
645 | 645 | 'messengers_to_validate_with' => array('email'), |
646 | 646 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | //register registration cancelled message type |
651 | 651 | $setup_args = array( |
652 | 652 | 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
653 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
653 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'), |
|
654 | 654 | 'messengers_to_activate_with' => array('email'), |
655 | 655 | 'messengers_to_validate_with' => array('email'), |
656 | 656 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | //register payment failed message type |
662 | 662 | $setup_args = array( |
663 | 663 | 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
664 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
664 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'), |
|
665 | 665 | 'messengers_to_activate_with' => array('email'), |
666 | 666 | 'messengers_to_validate_with' => array('email'), |
667 | 667 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | //register payment declined message type |
672 | 672 | $setup_args = array( |
673 | 673 | 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
674 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
674 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'), |
|
675 | 675 | 'messengers_to_activate_with' => array('email'), |
676 | 676 | 'messengers_to_validate_with' => array('email'), |
677 | 677 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | { |
692 | 692 | $setup_args = array( |
693 | 693 | 'autoloadpaths' => array( |
694 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
694 | + EE_CAF_LIBRARIES.'shortcodes/' |
|
695 | 695 | ), |
696 | 696 | 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
697 | 697 | 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
5 | 5 | |
@@ -15,329 +15,329 @@ discard block |
||
15 | 15 | class EEM_Attendee extends EEM_CPT_Base |
16 | 16 | { |
17 | 17 | |
18 | - // private instance of the Attendee object |
|
19 | - protected static $_instance = null; |
|
18 | + // private instance of the Attendee object |
|
19 | + protected static $_instance = null; |
|
20 | 20 | |
21 | - /** |
|
22 | - * QST_system for questions are strings not ints now, |
|
23 | - * so these constants are deprecated. |
|
24 | - * Please instead use the EEM_Attendee::system_question_* constants |
|
25 | - * |
|
26 | - * @deprecated |
|
27 | - */ |
|
28 | - const fname_question_id = 1; |
|
21 | + /** |
|
22 | + * QST_system for questions are strings not ints now, |
|
23 | + * so these constants are deprecated. |
|
24 | + * Please instead use the EEM_Attendee::system_question_* constants |
|
25 | + * |
|
26 | + * @deprecated |
|
27 | + */ |
|
28 | + const fname_question_id = 1; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @deprecated |
|
32 | - */ |
|
33 | - const lname_question_id = 2; |
|
30 | + /** |
|
31 | + * @deprecated |
|
32 | + */ |
|
33 | + const lname_question_id = 2; |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @deprecated |
|
38 | - */ |
|
39 | - const email_question_id = 3; |
|
36 | + /** |
|
37 | + * @deprecated |
|
38 | + */ |
|
39 | + const email_question_id = 3; |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @deprecated |
|
44 | - */ |
|
45 | - const address_question_id = 4; |
|
42 | + /** |
|
43 | + * @deprecated |
|
44 | + */ |
|
45 | + const address_question_id = 4; |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @deprecated |
|
50 | - */ |
|
51 | - const address2_question_id = 5; |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @deprecated |
|
56 | - */ |
|
57 | - const city_question_id = 6; |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * @deprecated |
|
62 | - */ |
|
63 | - const state_question_id = 7; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @deprecated |
|
68 | - */ |
|
69 | - const country_question_id = 8; |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @deprecated |
|
74 | - */ |
|
75 | - const zip_question_id = 9; |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @deprecated |
|
80 | - */ |
|
81 | - const phone_question_id = 10; |
|
82 | - |
|
83 | - /** |
|
84 | - * When looking for questions that correspond to attendee fields, |
|
85 | - * look for the question with this QST_system value. |
|
86 | - * These replace the old constants like EEM_Attendee::*_question_id |
|
87 | - */ |
|
88 | - const system_question_fname = 'fname'; |
|
89 | - |
|
90 | - const system_question_lname = 'lname'; |
|
91 | - |
|
92 | - const system_question_email = 'email'; |
|
93 | - |
|
94 | - const system_question_address = 'address'; |
|
95 | - |
|
96 | - const system_question_address2 = 'address2'; |
|
97 | - |
|
98 | - const system_question_city = 'city'; |
|
99 | - |
|
100 | - const system_question_state = 'state'; |
|
101 | - |
|
102 | - const system_question_country = 'country'; |
|
103 | - |
|
104 | - const system_question_zip = 'zip'; |
|
105 | - |
|
106 | - const system_question_phone = 'phone'; |
|
107 | - |
|
108 | - /** |
|
109 | - * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
110 | - * also all the values of QST_system in the questions table, and values |
|
111 | - * are their corresponding Attendee field names |
|
112 | - * |
|
113 | - * @var array |
|
114 | - */ |
|
115 | - protected $_system_question_to_attendee_field_name = array( |
|
116 | - EEM_Attendee::system_question_fname => 'ATT_fname', |
|
117 | - EEM_Attendee::system_question_lname => 'ATT_lname', |
|
118 | - EEM_Attendee::system_question_email => 'ATT_email', |
|
119 | - EEM_Attendee::system_question_address => 'ATT_address', |
|
120 | - EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
121 | - EEM_Attendee::system_question_city => 'ATT_city', |
|
122 | - EEM_Attendee::system_question_state => 'STA_ID', |
|
123 | - EEM_Attendee::system_question_country => 'CNT_ISO', |
|
124 | - EEM_Attendee::system_question_zip => 'ATT_zip', |
|
125 | - EEM_Attendee::system_question_phone => 'ATT_phone', |
|
126 | - ); |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * private constructor to prevent direct creation |
|
132 | - * |
|
133 | - * @Constructor |
|
134 | - * @access protected |
|
135 | - * @param null $timezone |
|
136 | - */ |
|
137 | - protected function __construct($timezone = null) |
|
138 | - { |
|
139 | - $this->singular_item = __('Attendee', 'event_espresso'); |
|
140 | - $this->plural_item = __('Attendees', 'event_espresso'); |
|
141 | - $this->_tables = array( |
|
142 | - 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
143 | - 'Attendee_Meta' => new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID'), |
|
144 | - ); |
|
145 | - $this->_fields = array( |
|
146 | - 'Attendee_CPT' => array( |
|
147 | - 'ATT_ID' => new EE_Primary_Key_Int_Field('ID', __("Attendee ID", "event_espresso")), |
|
148 | - 'ATT_full_name' => new EE_Plain_Text_Field('post_title', __("Attendee Full Name", "event_espresso"), |
|
149 | - false, __("Unknown", "event_espresso")), |
|
150 | - 'ATT_bio' => new EE_Post_Content_Field('post_content', __("Attendee Biography", "event_espresso"), |
|
151 | - false, __("No Biography Provided", "event_espresso")), |
|
152 | - 'ATT_slug' => new EE_Slug_Field('post_name', __("Attendee URL Slug", "event_espresso"), false), |
|
153 | - 'ATT_created' => new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), |
|
154 | - false, EE_Datetime_Field::now), |
|
155 | - 'ATT_short_bio' => new EE_Simple_HTML_Field('post_excerpt', |
|
156 | - __("Attendee Short Biography", "event_espresso"), true, |
|
157 | - __("No Biography Provided", "event_espresso")), |
|
158 | - 'ATT_modified' => new EE_Datetime_Field('post_modified', |
|
159 | - __("Time Attendee Last Modified", "event_espresso"), false, EE_Datetime_Field::now), |
|
160 | - 'ATT_author' => new EE_WP_User_Field('post_author', |
|
161 | - __("Creator ID of the first Event attended", "event_espresso"), false), |
|
162 | - 'ATT_parent' => new EE_DB_Only_Int_Field('post_parent', |
|
163 | - __("Parent Attendee (unused)", "event_espresso"), false, 0), |
|
164 | - 'post_type' => new EE_WP_Post_Type_Field('espresso_attendees'), |
|
165 | - // EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'), |
|
166 | - 'status' => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'), |
|
167 | - false, 'publish'), |
|
168 | - ), |
|
169 | - 'Attendee_Meta' => array( |
|
170 | - 'ATTM_ID' => new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'), |
|
171 | - false), |
|
172 | - 'ATT_ID_fk' => new EE_DB_Only_Int_Field('ATT_ID', |
|
173 | - __("Foreign Key to Attendee in Post Table", "event_espresso"), false), |
|
174 | - 'ATT_fname' => new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''), |
|
175 | - 'ATT_lname' => new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''), |
|
176 | - 'ATT_address' => new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true, |
|
177 | - ''), |
|
178 | - 'ATT_address2' => new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true, |
|
179 | - ''), |
|
180 | - 'ATT_city' => new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''), |
|
181 | - 'STA_ID' => new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0, |
|
182 | - 'State'), |
|
183 | - 'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '', |
|
184 | - 'Country'), |
|
185 | - 'ATT_zip' => new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''), |
|
186 | - 'ATT_email' => new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''), |
|
187 | - 'ATT_phone' => new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, ''), |
|
188 | - ), |
|
189 | - ); |
|
190 | - $this->_model_relations = array( |
|
191 | - 'Registration' => new EE_Has_Many_Relation(), |
|
192 | - 'State' => new EE_Belongs_To_Relation(), |
|
193 | - 'Country' => new EE_Belongs_To_Relation(), |
|
194 | - 'Event' => new EE_HABTM_Relation('Registration', false), |
|
195 | - 'WP_User' => new EE_Belongs_To_Relation(), |
|
196 | - 'Message' => new EE_Has_Many_Any_Relation(false), |
|
197 | - //allow deletion of attendees even if they have messages in the queue for them. |
|
198 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
199 | - 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
200 | - ); |
|
201 | - $this->_caps_slug = 'contacts'; |
|
202 | - parent::__construct($timezone); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * Gets the name of the field on the attendee model corresponding to the system question string |
|
209 | - * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
210 | - * |
|
211 | - * @param string $system_question_string |
|
212 | - * @return string|null if not found |
|
213 | - */ |
|
214 | - public function get_attendee_field_for_system_question($system_question_string) |
|
215 | - { |
|
216 | - return isset($this->_system_question_to_attendee_field_name[$system_question_string]) |
|
217 | - ? $this->_system_question_to_attendee_field_name[$system_question_string] : null; |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
224 | - * @return array |
|
225 | - */ |
|
226 | - public function system_question_to_attendee_field_mapping(){ |
|
227 | - return $this->_system_question_to_attendee_field_name; |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
234 | - * |
|
235 | - * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
236 | - * @return EE_Attendee[] |
|
237 | - */ |
|
238 | - public function get_attendees_for_transaction($transaction_id_or_obj) |
|
239 | - { |
|
240 | - return $this->get_all(array( |
|
241 | - array( |
|
242 | - 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
243 | - ? $transaction_id_or_obj->ID() : $transaction_id_or_obj, |
|
244 | - ), |
|
245 | - )); |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * retrieve a single attendee from db via their ID |
|
252 | - * |
|
253 | - * @access public |
|
254 | - * @param $ATT_ID |
|
255 | - * @return mixed array on success, FALSE on fail |
|
256 | - * @deprecated |
|
257 | - */ |
|
258 | - public function get_attendee_by_ID($ATT_ID = false) |
|
259 | - { |
|
260 | - // retrieve a particular EE_Attendee |
|
261 | - return $this->get_one_by_ID($ATT_ID); |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * retrieve a single attendee from db via their ID |
|
268 | - * |
|
269 | - * @access public |
|
270 | - * @param array $where_cols_n_values |
|
271 | - * @return mixed array on success, FALSE on fail |
|
272 | - */ |
|
273 | - public function get_attendee($where_cols_n_values = array()) |
|
274 | - { |
|
275 | - if (empty($where_cols_n_values)) { |
|
276 | - return false; |
|
277 | - } |
|
278 | - $attendee = $this->get_all(array($where_cols_n_values)); |
|
279 | - if ( ! empty($attendee)) { |
|
280 | - return array_shift($attendee); |
|
281 | - } else { |
|
282 | - return false; |
|
283 | - } |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * Search for an existing Attendee record in the DB |
|
290 | - * |
|
291 | - * @access public |
|
292 | - * @param array $where_cols_n_values |
|
293 | - * @return bool|mixed |
|
294 | - */ |
|
295 | - public function find_existing_attendee($where_cols_n_values = null) |
|
296 | - { |
|
297 | - // search by combo of first and last names plus the email address |
|
298 | - $attendee_data_keys = array( |
|
299 | - 'ATT_fname' => $this->_ATT_fname, |
|
300 | - 'ATT_lname' => $this->_ATT_lname, |
|
301 | - 'ATT_email' => $this->_ATT_email, |
|
302 | - ); |
|
303 | - // no search params means attendee object already exists. |
|
304 | - $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values |
|
305 | - : $attendee_data_keys; |
|
306 | - $valid_data = true; |
|
307 | - // check for required values |
|
308 | - $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
309 | - ? $valid_data : false; |
|
310 | - $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
311 | - ? $valid_data : false; |
|
312 | - $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
313 | - ? $valid_data : false; |
|
314 | - if ($valid_data) { |
|
315 | - $attendee = $this->get_attendee($where_cols_n_values); |
|
316 | - if ($attendee instanceof EE_Attendee) { |
|
317 | - return $attendee; |
|
318 | - } |
|
319 | - } |
|
320 | - return false; |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate |
|
327 | - * EE_Attendee objects. |
|
328 | - * |
|
329 | - * @since 4.3.0 |
|
330 | - * @param array $ids array of EE_Registration ids |
|
331 | - * @return EE_Attendee[] |
|
332 | - */ |
|
333 | - public function get_array_of_contacts_from_reg_ids($ids) |
|
334 | - { |
|
335 | - $ids = (array)$ids; |
|
336 | - $_where = array( |
|
337 | - 'Registration.REG_ID' => array('in', $ids), |
|
338 | - ); |
|
339 | - return $this->get_all(array($_where)); |
|
340 | - } |
|
48 | + /** |
|
49 | + * @deprecated |
|
50 | + */ |
|
51 | + const address2_question_id = 5; |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @deprecated |
|
56 | + */ |
|
57 | + const city_question_id = 6; |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * @deprecated |
|
62 | + */ |
|
63 | + const state_question_id = 7; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @deprecated |
|
68 | + */ |
|
69 | + const country_question_id = 8; |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @deprecated |
|
74 | + */ |
|
75 | + const zip_question_id = 9; |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @deprecated |
|
80 | + */ |
|
81 | + const phone_question_id = 10; |
|
82 | + |
|
83 | + /** |
|
84 | + * When looking for questions that correspond to attendee fields, |
|
85 | + * look for the question with this QST_system value. |
|
86 | + * These replace the old constants like EEM_Attendee::*_question_id |
|
87 | + */ |
|
88 | + const system_question_fname = 'fname'; |
|
89 | + |
|
90 | + const system_question_lname = 'lname'; |
|
91 | + |
|
92 | + const system_question_email = 'email'; |
|
93 | + |
|
94 | + const system_question_address = 'address'; |
|
95 | + |
|
96 | + const system_question_address2 = 'address2'; |
|
97 | + |
|
98 | + const system_question_city = 'city'; |
|
99 | + |
|
100 | + const system_question_state = 'state'; |
|
101 | + |
|
102 | + const system_question_country = 'country'; |
|
103 | + |
|
104 | + const system_question_zip = 'zip'; |
|
105 | + |
|
106 | + const system_question_phone = 'phone'; |
|
107 | + |
|
108 | + /** |
|
109 | + * Keys are all the EEM_Attendee::system_question_* constants, which are |
|
110 | + * also all the values of QST_system in the questions table, and values |
|
111 | + * are their corresponding Attendee field names |
|
112 | + * |
|
113 | + * @var array |
|
114 | + */ |
|
115 | + protected $_system_question_to_attendee_field_name = array( |
|
116 | + EEM_Attendee::system_question_fname => 'ATT_fname', |
|
117 | + EEM_Attendee::system_question_lname => 'ATT_lname', |
|
118 | + EEM_Attendee::system_question_email => 'ATT_email', |
|
119 | + EEM_Attendee::system_question_address => 'ATT_address', |
|
120 | + EEM_Attendee::system_question_address2 => 'ATT_address2', |
|
121 | + EEM_Attendee::system_question_city => 'ATT_city', |
|
122 | + EEM_Attendee::system_question_state => 'STA_ID', |
|
123 | + EEM_Attendee::system_question_country => 'CNT_ISO', |
|
124 | + EEM_Attendee::system_question_zip => 'ATT_zip', |
|
125 | + EEM_Attendee::system_question_phone => 'ATT_phone', |
|
126 | + ); |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * private constructor to prevent direct creation |
|
132 | + * |
|
133 | + * @Constructor |
|
134 | + * @access protected |
|
135 | + * @param null $timezone |
|
136 | + */ |
|
137 | + protected function __construct($timezone = null) |
|
138 | + { |
|
139 | + $this->singular_item = __('Attendee', 'event_espresso'); |
|
140 | + $this->plural_item = __('Attendees', 'event_espresso'); |
|
141 | + $this->_tables = array( |
|
142 | + 'Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), |
|
143 | + 'Attendee_Meta' => new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID'), |
|
144 | + ); |
|
145 | + $this->_fields = array( |
|
146 | + 'Attendee_CPT' => array( |
|
147 | + 'ATT_ID' => new EE_Primary_Key_Int_Field('ID', __("Attendee ID", "event_espresso")), |
|
148 | + 'ATT_full_name' => new EE_Plain_Text_Field('post_title', __("Attendee Full Name", "event_espresso"), |
|
149 | + false, __("Unknown", "event_espresso")), |
|
150 | + 'ATT_bio' => new EE_Post_Content_Field('post_content', __("Attendee Biography", "event_espresso"), |
|
151 | + false, __("No Biography Provided", "event_espresso")), |
|
152 | + 'ATT_slug' => new EE_Slug_Field('post_name', __("Attendee URL Slug", "event_espresso"), false), |
|
153 | + 'ATT_created' => new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), |
|
154 | + false, EE_Datetime_Field::now), |
|
155 | + 'ATT_short_bio' => new EE_Simple_HTML_Field('post_excerpt', |
|
156 | + __("Attendee Short Biography", "event_espresso"), true, |
|
157 | + __("No Biography Provided", "event_espresso")), |
|
158 | + 'ATT_modified' => new EE_Datetime_Field('post_modified', |
|
159 | + __("Time Attendee Last Modified", "event_espresso"), false, EE_Datetime_Field::now), |
|
160 | + 'ATT_author' => new EE_WP_User_Field('post_author', |
|
161 | + __("Creator ID of the first Event attended", "event_espresso"), false), |
|
162 | + 'ATT_parent' => new EE_DB_Only_Int_Field('post_parent', |
|
163 | + __("Parent Attendee (unused)", "event_espresso"), false, 0), |
|
164 | + 'post_type' => new EE_WP_Post_Type_Field('espresso_attendees'), |
|
165 | + // EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'), |
|
166 | + 'status' => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'), |
|
167 | + false, 'publish'), |
|
168 | + ), |
|
169 | + 'Attendee_Meta' => array( |
|
170 | + 'ATTM_ID' => new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'), |
|
171 | + false), |
|
172 | + 'ATT_ID_fk' => new EE_DB_Only_Int_Field('ATT_ID', |
|
173 | + __("Foreign Key to Attendee in Post Table", "event_espresso"), false), |
|
174 | + 'ATT_fname' => new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''), |
|
175 | + 'ATT_lname' => new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''), |
|
176 | + 'ATT_address' => new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true, |
|
177 | + ''), |
|
178 | + 'ATT_address2' => new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true, |
|
179 | + ''), |
|
180 | + 'ATT_city' => new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''), |
|
181 | + 'STA_ID' => new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0, |
|
182 | + 'State'), |
|
183 | + 'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '', |
|
184 | + 'Country'), |
|
185 | + 'ATT_zip' => new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''), |
|
186 | + 'ATT_email' => new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''), |
|
187 | + 'ATT_phone' => new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, ''), |
|
188 | + ), |
|
189 | + ); |
|
190 | + $this->_model_relations = array( |
|
191 | + 'Registration' => new EE_Has_Many_Relation(), |
|
192 | + 'State' => new EE_Belongs_To_Relation(), |
|
193 | + 'Country' => new EE_Belongs_To_Relation(), |
|
194 | + 'Event' => new EE_HABTM_Relation('Registration', false), |
|
195 | + 'WP_User' => new EE_Belongs_To_Relation(), |
|
196 | + 'Message' => new EE_Has_Many_Any_Relation(false), |
|
197 | + //allow deletion of attendees even if they have messages in the queue for them. |
|
198 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
199 | + 'Term_Taxonomy' => new EE_HABTM_Relation('Term_Relationship'), |
|
200 | + ); |
|
201 | + $this->_caps_slug = 'contacts'; |
|
202 | + parent::__construct($timezone); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * Gets the name of the field on the attendee model corresponding to the system question string |
|
209 | + * which should be one of the keys from EEM_Attendee::_system_question_to_attendee_field_name |
|
210 | + * |
|
211 | + * @param string $system_question_string |
|
212 | + * @return string|null if not found |
|
213 | + */ |
|
214 | + public function get_attendee_field_for_system_question($system_question_string) |
|
215 | + { |
|
216 | + return isset($this->_system_question_to_attendee_field_name[$system_question_string]) |
|
217 | + ? $this->_system_question_to_attendee_field_name[$system_question_string] : null; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
|
224 | + * @return array |
|
225 | + */ |
|
226 | + public function system_question_to_attendee_field_mapping(){ |
|
227 | + return $this->_system_question_to_attendee_field_name; |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * Gets all the attendees for a transaction (by using the esp_registration as a join table) |
|
234 | + * |
|
235 | + * @param EE_Transaction /int $transaction_id_or_obj EE_Transaction or its ID |
|
236 | + * @return EE_Attendee[] |
|
237 | + */ |
|
238 | + public function get_attendees_for_transaction($transaction_id_or_obj) |
|
239 | + { |
|
240 | + return $this->get_all(array( |
|
241 | + array( |
|
242 | + 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction |
|
243 | + ? $transaction_id_or_obj->ID() : $transaction_id_or_obj, |
|
244 | + ), |
|
245 | + )); |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * retrieve a single attendee from db via their ID |
|
252 | + * |
|
253 | + * @access public |
|
254 | + * @param $ATT_ID |
|
255 | + * @return mixed array on success, FALSE on fail |
|
256 | + * @deprecated |
|
257 | + */ |
|
258 | + public function get_attendee_by_ID($ATT_ID = false) |
|
259 | + { |
|
260 | + // retrieve a particular EE_Attendee |
|
261 | + return $this->get_one_by_ID($ATT_ID); |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * retrieve a single attendee from db via their ID |
|
268 | + * |
|
269 | + * @access public |
|
270 | + * @param array $where_cols_n_values |
|
271 | + * @return mixed array on success, FALSE on fail |
|
272 | + */ |
|
273 | + public function get_attendee($where_cols_n_values = array()) |
|
274 | + { |
|
275 | + if (empty($where_cols_n_values)) { |
|
276 | + return false; |
|
277 | + } |
|
278 | + $attendee = $this->get_all(array($where_cols_n_values)); |
|
279 | + if ( ! empty($attendee)) { |
|
280 | + return array_shift($attendee); |
|
281 | + } else { |
|
282 | + return false; |
|
283 | + } |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * Search for an existing Attendee record in the DB |
|
290 | + * |
|
291 | + * @access public |
|
292 | + * @param array $where_cols_n_values |
|
293 | + * @return bool|mixed |
|
294 | + */ |
|
295 | + public function find_existing_attendee($where_cols_n_values = null) |
|
296 | + { |
|
297 | + // search by combo of first and last names plus the email address |
|
298 | + $attendee_data_keys = array( |
|
299 | + 'ATT_fname' => $this->_ATT_fname, |
|
300 | + 'ATT_lname' => $this->_ATT_lname, |
|
301 | + 'ATT_email' => $this->_ATT_email, |
|
302 | + ); |
|
303 | + // no search params means attendee object already exists. |
|
304 | + $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values |
|
305 | + : $attendee_data_keys; |
|
306 | + $valid_data = true; |
|
307 | + // check for required values |
|
308 | + $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) |
|
309 | + ? $valid_data : false; |
|
310 | + $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) |
|
311 | + ? $valid_data : false; |
|
312 | + $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) |
|
313 | + ? $valid_data : false; |
|
314 | + if ($valid_data) { |
|
315 | + $attendee = $this->get_attendee($where_cols_n_values); |
|
316 | + if ($attendee instanceof EE_Attendee) { |
|
317 | + return $attendee; |
|
318 | + } |
|
319 | + } |
|
320 | + return false; |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate |
|
327 | + * EE_Attendee objects. |
|
328 | + * |
|
329 | + * @since 4.3.0 |
|
330 | + * @param array $ids array of EE_Registration ids |
|
331 | + * @return EE_Attendee[] |
|
332 | + */ |
|
333 | + public function get_array_of_contacts_from_reg_ids($ids) |
|
334 | + { |
|
335 | + $ids = (array)$ids; |
|
336 | + $_where = array( |
|
337 | + 'Registration.REG_ID' => array('in', $ids), |
|
338 | + ); |
|
339 | + return $this->get_all(array($_where)); |
|
340 | + } |
|
341 | 341 | |
342 | 342 | |
343 | 343 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * Gets mapping from esp_question.QST_system values to their corresponding attendee field names |
224 | 224 | * @return array |
225 | 225 | */ |
226 | - public function system_question_to_attendee_field_mapping(){ |
|
226 | + public function system_question_to_attendee_field_mapping() { |
|
227 | 227 | return $this->_system_question_to_attendee_field_name; |
228 | 228 | } |
229 | 229 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public function get_array_of_contacts_from_reg_ids($ids) |
334 | 334 | { |
335 | - $ids = (array)$ids; |
|
335 | + $ids = (array) $ids; |
|
336 | 336 | $_where = array( |
337 | 337 | 'Registration.REG_ID' => array('in', $ids), |
338 | 338 | ); |