@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * error_handler |
90 | 90 | * @access public |
91 | - * @param $code |
|
91 | + * @param integer $code |
|
92 | 92 | * @param $message |
93 | 93 | * @param $file |
94 | 94 | * @param $line |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | /** |
190 | 190 | * _format_error |
191 | 191 | * @access private |
192 | - * @param $code |
|
192 | + * @param string $code |
|
193 | 193 | * @param $message |
194 | 194 | * @param $file |
195 | 195 | * @param $line |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | * |
937 | 937 | * @access public |
938 | 938 | * @param string $return_url |
939 | - * @return array |
|
939 | + * @return string |
|
940 | 940 | */ |
941 | 941 | public static function get_persistent_admin_notices( $return_url = '' ) { |
942 | 942 | $notices = ''; |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | * |
962 | 962 | * @access public |
963 | 963 | * @param bool $force_print |
964 | - * @return void |
|
964 | + * @return null|string |
|
965 | 965 | */ |
966 | 966 | private static function _print_scripts( $force_print = FALSE ) { |
967 | 967 | if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -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' )); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @access public |
260 | 260 | * @return boolean |
261 | 261 | */ |
262 | - public static function has_error(){ |
|
262 | + public static function has_error() { |
|
263 | 263 | return self::$_error_count ? TRUE : FALSE; |
264 | 264 | } |
265 | 265 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @access public |
271 | 271 | * @echo string |
272 | 272 | */ |
273 | - public function display_errors(){ |
|
273 | + public function display_errors() { |
|
274 | 274 | |
275 | 275 | $trace_details = ''; |
276 | 276 | |
@@ -331,18 +331,18 @@ discard block |
||
331 | 331 | </style> |
332 | 332 | <div id="ee-error-message" class="error">'; |
333 | 333 | |
334 | - if ( ! WP_DEBUG ) { |
|
334 | + if ( ! WP_DEBUG) { |
|
335 | 335 | $output .= ' |
336 | 336 | <p>'; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // cycle thru errors |
340 | - foreach ( self::$_all_exceptions as $time => $ex ) { |
|
340 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
341 | 341 | |
342 | 342 | // process trace info |
343 | - if ( empty( $ex['trace'] )) { |
|
343 | + if (empty($ex['trace'])) { |
|
344 | 344 | |
345 | - $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' ); |
|
345 | + $trace_details .= __('Sorry, but no trace information was available for this exception.', 'event_espresso'); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
@@ -357,50 +357,50 @@ discard block |
||
357 | 357 | <th scope="col" align="left">Method( arguments )</th> |
358 | 358 | </tr>'; |
359 | 359 | |
360 | - $last_on_stack = count( $ex['trace'] ) - 1; |
|
360 | + $last_on_stack = count($ex['trace']) - 1; |
|
361 | 361 | // reverse array so that stack is in proper chronological order |
362 | - $sorted_trace = array_reverse( $ex['trace'] ); |
|
362 | + $sorted_trace = array_reverse($ex['trace']); |
|
363 | 363 | |
364 | - foreach ( $sorted_trace as $nmbr => $trace ) { |
|
364 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
365 | 365 | |
366 | - $file = isset( $trace['file'] ) ? $trace['file'] : '' ; |
|
367 | - $class = isset( $trace['class'] ) ? $trace['class'] : ''; |
|
368 | - $type = isset( $trace['type'] ) ? $trace['type'] : ''; |
|
369 | - $function = isset( $trace['function'] ) ? $trace['function'] : ''; |
|
370 | - $args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : ''; |
|
371 | - $line = isset( $trace['line'] ) ? $trace['line'] : ''; |
|
366 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
367 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
368 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
369 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
370 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
371 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
372 | 372 | $zebra = $nmbr % 2 ? ' odd' : ''; |
373 | 373 | |
374 | - if ( empty( $file ) && ! empty( $class )) { |
|
375 | - $a = new ReflectionClass( $class ); |
|
374 | + if (empty($file) && ! empty($class)) { |
|
375 | + $a = new ReflectionClass($class); |
|
376 | 376 | $file = $a->getFileName(); |
377 | - if ( empty( $line ) && ! empty( $function )) { |
|
378 | - $b = new ReflectionMethod( $class, $function ); |
|
377 | + if (empty($line) && ! empty($function)) { |
|
378 | + $b = new ReflectionMethod($class, $function); |
|
379 | 379 | $line = $b->getStartLine(); |
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
383 | - if ( $nmbr == $last_on_stack ) { |
|
383 | + if ($nmbr == $last_on_stack) { |
|
384 | 384 | $file = $ex['file'] != '' ? $ex['file'] : $file; |
385 | 385 | $line = $ex['line'] != '' ? $ex['line'] : $line; |
386 | - $error_code = self::generate_error_code ( $file, $trace['function'], $line ); |
|
386 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
387 | 387 | } |
388 | 388 | |
389 | - $nmbr_dsply = ! empty( $nmbr ) ? $nmbr : ' '; |
|
390 | - $line_dsply = ! empty( $line ) ? $line : ' '; |
|
391 | - $file_dsply = ! empty( $file ) ? $file : ' '; |
|
392 | - $class_dsply = ! empty( $class ) ? $class : ' '; |
|
393 | - $type_dsply = ! empty( $type ) ? $type : ' '; |
|
394 | - $function_dsply = ! empty( $function ) ? $function : ' '; |
|
395 | - $args_dsply = ! empty( $args ) ? '( ' . $args . ' )' : ''; |
|
389 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
390 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
391 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
392 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
393 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
394 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
395 | + $args_dsply = ! empty($args) ? '( '.$args.' )' : ''; |
|
396 | 396 | |
397 | 397 | $trace_details .= ' |
398 | 398 | <tr> |
399 | - <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
|
400 | - <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
|
401 | - <td align="left" class="' . $zebra . '">' . $file_dsply . '</td> |
|
402 | - <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
|
403 | - <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
|
399 | + <td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td> |
|
400 | + <td align="right" class="' . $zebra.'">'.$line_dsply.'</td> |
|
401 | + <td align="left" class="' . $zebra.'">'.$file_dsply.'</td> |
|
402 | + <td align="left" class="' . $zebra.'">'.$class_dsply.'</td> |
|
403 | + <td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td> |
|
404 | 404 | </tr>'; |
405 | 405 | |
406 | 406 | |
@@ -415,9 +415,9 @@ discard block |
||
415 | 415 | $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
416 | 416 | |
417 | 417 | // add generic non-identifying messages for non-privileged uesrs |
418 | - if ( ! WP_DEBUG ) { |
|
418 | + if ( ! WP_DEBUG) { |
|
419 | 419 | |
420 | - $output .= '<span class="ee-error-user-msg-spn">' . trim( $ex['msg'] ) . '</span> <sup>' . $ex['code'] . '</sup><br />'; |
|
420 | + $output .= '<span class="ee-error-user-msg-spn">'.trim($ex['msg']).'</span> <sup>'.$ex['code'].'</sup><br />'; |
|
421 | 421 | |
422 | 422 | } else { |
423 | 423 | |
@@ -425,24 +425,24 @@ discard block |
||
425 | 425 | $output .= ' |
426 | 426 | <div class="ee-error-dev-msg-dv"> |
427 | 427 | <p class="ee-error-dev-msg-pg"> |
428 | - <strong class="ee-error-dev-msg-str">An ' . $ex['name'] . ' exception was thrown!</strong> <span>code: ' . $ex['code'] . '</span><br /> |
|
429 | - <span class="big-text">"' . trim( $ex['msg'] ) . '"</span><br/> |
|
430 | - <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 . '"> |
|
431 | - ' . __( 'click to view backtrace and class/method details', 'event_espresso' ) . ' |
|
428 | + <strong class="ee-error-dev-msg-str">An ' . $ex['name'].' exception was thrown!</strong> <span>code: '.$ex['code'].'</span><br /> |
|
429 | + <span class="big-text">"' . trim($ex['msg']).'"</span><br/> |
|
430 | + <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.'"> |
|
431 | + ' . __('click to view backtrace and class/method details', 'event_espresso').' |
|
432 | 432 | </a><br /> |
433 | 433 | <span class="small-text lt-grey-text">'.$ex['file'].' ( line no: '.$ex['line'].' )</span> |
434 | 434 | </p> |
435 | - <div id="ee-error-trace-' . self::$_error_count . $time . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
435 | + <div id="ee-error-trace-' . self::$_error_count.$time.'-dv" class="ee-error-trace-dv" style="display: none;"> |
|
436 | 436 | ' . $trace_details; |
437 | 437 | |
438 | - if ( ! empty( $class )) { |
|
438 | + if ( ! empty($class)) { |
|
439 | 439 | $output .= ' |
440 | 440 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
441 | 441 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
442 | 442 | <h3>Class Details</h3>'; |
443 | - $a = new ReflectionClass( $class ); |
|
443 | + $a = new ReflectionClass($class); |
|
444 | 444 | $output .= ' |
445 | - <pre>' . $a . '</pre> |
|
445 | + <pre>' . $a.'</pre> |
|
446 | 446 | </div> |
447 | 447 | </div>'; |
448 | 448 | } |
@@ -454,14 +454,14 @@ discard block |
||
454 | 454 | |
455 | 455 | } |
456 | 456 | |
457 | - $this->write_to_error_log( $time, $ex ); |
|
457 | + $this->write_to_error_log($time, $ex); |
|
458 | 458 | |
459 | 459 | } |
460 | 460 | |
461 | 461 | // remove last linebreak |
462 | - $output = substr( $output, 0, ( count( $output ) - 7 )); |
|
462 | + $output = substr($output, 0, (count($output) - 7)); |
|
463 | 463 | |
464 | - if ( ! WP_DEBUG ) { |
|
464 | + if ( ! WP_DEBUG) { |
|
465 | 465 | $output .= ' |
466 | 466 | </p>'; |
467 | 467 | } |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | $output .= ' |
470 | 470 | </div>'; |
471 | 471 | |
472 | - $output .= self::_print_scripts( TRUE ); |
|
472 | + $output .= self::_print_scripts(TRUE); |
|
473 | 473 | |
474 | - if ( defined( 'DOING_AJAX' )) { |
|
475 | - echo json_encode( array( 'error' => $output )); |
|
474 | + if (defined('DOING_AJAX')) { |
|
475 | + echo json_encode(array('error' => $output)); |
|
476 | 476 | exit(); |
477 | 477 | } |
478 | 478 | |
@@ -492,29 +492,29 @@ discard block |
||
492 | 492 | * @ param array $arguments |
493 | 493 | * @ return string |
494 | 494 | */ |
495 | - private function _convert_args_to_string ( $arguments = array(), $array = FALSE ) { |
|
495 | + private function _convert_args_to_string($arguments = array(), $array = FALSE) { |
|
496 | 496 | |
497 | 497 | $arg_string = ''; |
498 | - if ( ! empty( $arguments )) { |
|
498 | + if ( ! empty($arguments)) { |
|
499 | 499 | |
500 | 500 | $args = array(); |
501 | 501 | |
502 | - foreach ( $arguments as $arg ) { |
|
502 | + foreach ($arguments as $arg) { |
|
503 | 503 | |
504 | - if ( ! empty( $arg )) { |
|
504 | + if ( ! empty($arg)) { |
|
505 | 505 | |
506 | - if ( is_string( $arg )) { |
|
507 | - $args[] = " '" . $arg . "'"; |
|
508 | - } elseif ( is_array( $arg )) { |
|
509 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string( $arg, TRUE ); |
|
510 | - } elseif ( is_null( $arg )) { |
|
506 | + if (is_string($arg)) { |
|
507 | + $args[] = " '".$arg."'"; |
|
508 | + } elseif (is_array($arg)) { |
|
509 | + $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, TRUE); |
|
510 | + } elseif (is_null($arg)) { |
|
511 | 511 | $args[] = ' NULL'; |
512 | - } elseif ( is_bool( $arg )) { |
|
513 | - $args[] = ( $arg ) ? ' TRUE' : ' FALSE'; |
|
514 | - } elseif ( is_object( $arg )) { |
|
515 | - $args[] = ' OBJECT ' . get_class( $arg ); |
|
516 | - } elseif ( is_resource( $arg )) { |
|
517 | - $args[] = get_resource_type( $arg ); |
|
512 | + } elseif (is_bool($arg)) { |
|
513 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
514 | + } elseif (is_object($arg)) { |
|
515 | + $args[] = ' OBJECT '.get_class($arg); |
|
516 | + } elseif (is_resource($arg)) { |
|
517 | + $args[] = get_resource_type($arg); |
|
518 | 518 | } else { |
519 | 519 | $args[] = $arg; |
520 | 520 | } |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | } |
523 | 523 | |
524 | 524 | } |
525 | - $arg_string = implode( ', ', $args ); |
|
525 | + $arg_string = implode(', ', $args); |
|
526 | 526 | } |
527 | - if ( $array ) { |
|
527 | + if ($array) { |
|
528 | 528 | $arg_string .= ' )'; |
529 | 529 | } |
530 | 530 | return $arg_string; |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * @param string $line the line number where the error occurred - just use __LINE__ |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public static function add_error( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
548 | - self::_add_notice ( 'errors', $msg, $file, $func, $line ); |
|
547 | + public static function add_error($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
548 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
549 | 549 | self::$_error_count++; |
550 | 550 | } |
551 | 551 | |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | * @param string $line the line number where the error occurred - just use __LINE__ |
564 | 564 | * @return void |
565 | 565 | */ |
566 | - public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
567 | - self::_add_notice ( 'success', $msg, $file, $func, $line ); |
|
566 | + public static function add_success($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
567 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | |
@@ -581,8 +581,8 @@ discard block |
||
581 | 581 | * @param string $line the line number where the error occurred - just use __LINE__ |
582 | 582 | * @return void |
583 | 583 | */ |
584 | - public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
585 | - self::_add_notice ( 'attention', $msg, $file, $func, $line ); |
|
584 | + public static function add_attention($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
585 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | |
@@ -600,12 +600,12 @@ discard block |
||
600 | 600 | * @param string $line the line number where the error occurred - just use __LINE__ |
601 | 601 | * @return void |
602 | 602 | */ |
603 | - private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
604 | - if ( empty( $msg )) { |
|
603 | + private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
604 | + if (empty($msg)) { |
|
605 | 605 | EE_Error::doing_it_wrong( |
606 | - 'EE_Error::add_' . $type . '()', |
|
606 | + 'EE_Error::add_'.$type.'()', |
|
607 | 607 | sprintf( |
608 | - __( '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' ), |
|
608 | + __('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'), |
|
609 | 609 | $type, |
610 | 610 | $file, |
611 | 611 | $line |
@@ -613,27 +613,27 @@ discard block |
||
613 | 613 | EVENT_ESPRESSO_VERSION |
614 | 614 | ); |
615 | 615 | } |
616 | - if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) { |
|
616 | + if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
617 | 617 | EE_Error::doing_it_wrong( |
618 | 618 | 'EE_Error::add_error()', |
619 | - __('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' ), |
|
619 | + __('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'), |
|
620 | 620 | EVENT_ESPRESSO_VERSION |
621 | 621 | ); |
622 | 622 | } |
623 | 623 | // get separate user and developer messages if they exist |
624 | - $msg = explode( '||', $msg ); |
|
624 | + $msg = explode('||', $msg); |
|
625 | 625 | $user_msg = $msg[0]; |
626 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
626 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
627 | 627 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
628 | 628 | // add notice if message exists |
629 | - if ( ! empty( $msg )) { |
|
629 | + if ( ! empty($msg)) { |
|
630 | 630 | // get error code, but only on error |
631 | - if ( WP_DEBUG && $type == 'errors' ) { |
|
632 | - $msg .= '<br/><span class="tiny-text">' . EE_Error::generate_error_code( $file, $func, $line ) . '</span>'; |
|
631 | + if (WP_DEBUG && $type == 'errors') { |
|
632 | + $msg .= '<br/><span class="tiny-text">'.EE_Error::generate_error_code($file, $func, $line).'</span>'; |
|
633 | 633 | } |
634 | 634 | // add notice |
635 | - self::$_espresso_notices[ $type ][] = $msg; |
|
636 | - add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 ); |
|
635 | + self::$_espresso_notices[$type][] = $msg; |
|
636 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | } |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | * @access private |
688 | 688 | * @return void |
689 | 689 | */ |
690 | - public static function reset_notices(){ |
|
690 | + public static function reset_notices() { |
|
691 | 691 | self::$_espresso_notices['success'] = FALSE; |
692 | 692 | self::$_espresso_notices['attention'] = FALSE; |
693 | 693 | self::$_espresso_notices['errors'] = FALSE; |
@@ -700,14 +700,14 @@ discard block |
||
700 | 700 | * @access public |
701 | 701 | * @return int |
702 | 702 | */ |
703 | - public static function has_notices(){ |
|
703 | + public static function has_notices() { |
|
704 | 704 | $has_notices = 0; |
705 | 705 | // check for success messages |
706 | - $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
|
706 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices; |
|
707 | 707 | // check for attention messages |
708 | - $has_notices = self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ? 2 : $has_notices; |
|
708 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices; |
|
709 | 709 | // check for error messages |
710 | - $has_notices = self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ? 1 : $has_notices; |
|
710 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices; |
|
711 | 711 | return $has_notices; |
712 | 712 | } |
713 | 713 | |
@@ -722,8 +722,8 @@ discard block |
||
722 | 722 | * @param boolean $remove_empty whether or not to unset empty messages |
723 | 723 | * @return array |
724 | 724 | */ |
725 | - public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
|
726 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
725 | + public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) { |
|
726 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
727 | 727 | |
728 | 728 | $success_messages = ''; |
729 | 729 | $attention_messages = ''; |
@@ -733,44 +733,44 @@ discard block |
||
733 | 733 | // 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' ); |
734 | 734 | |
735 | 735 | // either save notices to the db |
736 | - if ( $save_to_transient ) { |
|
737 | - update_option( 'ee_notices', self::$_espresso_notices ); |
|
736 | + if ($save_to_transient) { |
|
737 | + update_option('ee_notices', self::$_espresso_notices); |
|
738 | 738 | return; |
739 | 739 | } |
740 | 740 | // grab any notices that have been previously saved |
741 | - if ( $notices = get_option( 'ee_notices', FALSE )) { |
|
742 | - foreach ( $notices as $type => $notice ) { |
|
743 | - if ( is_array( $notice ) && ! empty( $notice )) { |
|
741 | + if ($notices = get_option('ee_notices', FALSE)) { |
|
742 | + foreach ($notices as $type => $notice) { |
|
743 | + if (is_array($notice) && ! empty($notice)) { |
|
744 | 744 | // make sure that existsing notice type is an array |
745 | - self::$_espresso_notices[ $type ] = is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array(); |
|
745 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array(); |
|
746 | 746 | // merge stored notices with any newly created ones |
747 | - self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice ); |
|
747 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
748 | 748 | $print_scripts = TRUE; |
749 | 749 | } |
750 | 750 | } |
751 | 751 | // now clear any stored notices |
752 | - update_option( 'ee_notices', FALSE ); |
|
752 | + update_option('ee_notices', FALSE); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | // check for success messages |
756 | - if ( self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] )) { |
|
756 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
757 | 757 | // combine messages |
758 | - $success_messages .= implode( self::$_espresso_notices['success'], '<br />' ); |
|
758 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br />'); |
|
759 | 759 | $print_scripts = TRUE; |
760 | 760 | } |
761 | 761 | |
762 | 762 | // check for attention messages |
763 | - if ( self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ) { |
|
763 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
764 | 764 | // combine messages |
765 | - $attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' ); |
|
765 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />'); |
|
766 | 766 | $print_scripts = TRUE; |
767 | 767 | } |
768 | 768 | |
769 | 769 | // check for error messages |
770 | - if ( self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ) { |
|
771 | - $error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' ); |
|
770 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
771 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso'); |
|
772 | 772 | // combine messages |
773 | - $error_messages .= implode( self::$_espresso_notices['errors'], '<br />' ); |
|
773 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br />'); |
|
774 | 774 | $print_scripts = TRUE; |
775 | 775 | } |
776 | 776 | |
@@ -784,21 +784,21 @@ discard block |
||
784 | 784 | $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
785 | 785 | $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
786 | 786 | //showMessage( $success_messages ); |
787 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>'; |
|
787 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>'; |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | if ($attention_messages != '') { |
791 | 791 | $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
792 | 792 | $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
793 | 793 | //showMessage( $error_messages, TRUE ); |
794 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>'; |
|
794 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>'; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | if ($error_messages != '') { |
798 | 798 | $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
799 | 799 | $css_class = is_admin() ? 'error' : 'error fade-away'; |
800 | 800 | //showMessage( $error_messages, TRUE ); |
801 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>'; |
|
801 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>'; |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | $notices .= '</div>'; |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | 'errors' => $error_messages |
812 | 812 | ); |
813 | 813 | |
814 | - if ( $remove_empty ) { |
|
814 | + if ($remove_empty) { |
|
815 | 815 | // remove empty notices |
816 | 816 | foreach ($notices as $type => $notice) { |
817 | 817 | if (empty($notice)) { |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | } |
822 | 822 | } |
823 | 823 | |
824 | - if ( $print_scripts ) { |
|
824 | + if ($print_scripts) { |
|
825 | 825 | self::_print_scripts(); |
826 | 826 | } |
827 | 827 | |
@@ -841,17 +841,17 @@ discard block |
||
841 | 841 | * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
842 | 842 | * @return void |
843 | 843 | */ |
844 | - public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
|
845 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
846 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
844 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) { |
|
845 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
846 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
847 | 847 | //maybe initialize persistent_admin_notices |
848 | - if ( empty( $persistent_admin_notices )) { |
|
849 | - add_option( 'ee_pers_admin_notices', array(), '', 'no' ); |
|
848 | + if (empty($persistent_admin_notices)) { |
|
849 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
850 | 850 | } |
851 | - $pan_name = sanitize_key( $pan_name ); |
|
852 | - if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) { |
|
853 | - $persistent_admin_notices[ $pan_name ] = $pan_message; |
|
854 | - update_option( 'ee_pers_admin_notices', $persistent_admin_notices ); |
|
851 | + $pan_name = sanitize_key($pan_name); |
|
852 | + if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
853 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
854 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | } |
@@ -867,34 +867,34 @@ discard block |
||
867 | 867 | * @param bool $return_immediately |
868 | 868 | * @return void |
869 | 869 | */ |
870 | - public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) { |
|
871 | - $pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name; |
|
872 | - if ( ! empty( $pan_name )) { |
|
873 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
870 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) { |
|
871 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
872 | + if ( ! empty($pan_name)) { |
|
873 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
874 | 874 | // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
875 | - if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) { |
|
875 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
876 | 876 | // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
877 | - if ( $purge ) { |
|
878 | - unset( $persistent_admin_notices[ $pan_name ] ); |
|
877 | + if ($purge) { |
|
878 | + unset($persistent_admin_notices[$pan_name]); |
|
879 | 879 | } else { |
880 | - $persistent_admin_notices[ $pan_name ] = NULL; |
|
880 | + $persistent_admin_notices[$pan_name] = NULL; |
|
881 | 881 | } |
882 | - if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) { |
|
883 | - EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
882 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) { |
|
883 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
884 | 884 | } |
885 | 885 | } |
886 | 886 | } |
887 | - if ( $return_immediately ) { |
|
887 | + if ($return_immediately) { |
|
888 | 888 | return; |
889 | - } else if ( EE_Registry::instance()->REQ->ajax ) { |
|
889 | + } else if (EE_Registry::instance()->REQ->ajax) { |
|
890 | 890 | // grab any notices and concatenate into string |
891 | - echo json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE )))); |
|
891 | + echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE)))); |
|
892 | 892 | exit(); |
893 | 893 | } else { |
894 | 894 | // save errors to a transient to be displayed on next request (after redirect) |
895 | - EE_Error::get_notices( FALSE, TRUE ); |
|
896 | - $return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : ''; |
|
897 | - wp_safe_redirect( urldecode( $return_url )); |
|
895 | + EE_Error::get_notices(FALSE, TRUE); |
|
896 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
897 | + wp_safe_redirect(urldecode($return_url)); |
|
898 | 898 | } |
899 | 899 | } |
900 | 900 | |
@@ -909,20 +909,20 @@ discard block |
||
909 | 909 | * @param string $return_url URL to go back to aftger nag notice is dismissed |
910 | 910 | * @return string |
911 | 911 | */ |
912 | - public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
|
913 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
912 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') { |
|
913 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
914 | 914 | $args = array( |
915 | 915 | 'nag_notice' => $pan_name, |
916 | - 'return_url' => urlencode( $return_url ), |
|
916 | + 'return_url' => urlencode($return_url), |
|
917 | 917 | 'ajax_url' => WP_AJAX_URL, |
918 | - 'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' ) |
|
918 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso') |
|
919 | 919 | ); |
920 | - wp_localize_script( 'espresso_core', 'ee_dismiss', $args ); |
|
920 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
921 | 921 | return ' |
922 | - <div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
923 | - <p>' . $pan_message . '</p> |
|
924 | - <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '"> |
|
925 | - <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .' |
|
922 | + <div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
923 | + <p>' . $pan_message.'</p> |
|
924 | + <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'"> |
|
925 | + <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').' |
|
926 | 926 | </a> |
927 | 927 | <div style="clear:both;"></div> |
928 | 928 | </div>'; |
@@ -938,17 +938,17 @@ discard block |
||
938 | 938 | * @param string $return_url |
939 | 939 | * @return array |
940 | 940 | */ |
941 | - public static function get_persistent_admin_notices( $return_url = '' ) { |
|
941 | + public static function get_persistent_admin_notices($return_url = '') { |
|
942 | 942 | $notices = ''; |
943 | 943 | // check for persistent admin notices |
944 | - if ( $persistent_admin_notices = get_option( 'ee_pers_admin_notices', FALSE )) { |
|
944 | + if ($persistent_admin_notices = get_option('ee_pers_admin_notices', FALSE)) { |
|
945 | 945 | // load scripts |
946 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
947 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
948 | - wp_enqueue_script( 'ee_error_js' ); |
|
946 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
947 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
948 | + wp_enqueue_script('ee_error_js'); |
|
949 | 949 | // and display notices |
950 | - foreach( $persistent_admin_notices as $pan_name => $pan_message ) { |
|
951 | - $notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url ); |
|
950 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
951 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
952 | 952 | } |
953 | 953 | } |
954 | 954 | return $notices; |
@@ -963,26 +963,26 @@ discard block |
||
963 | 963 | * @param bool $force_print |
964 | 964 | * @return void |
965 | 965 | */ |
966 | - private static function _print_scripts( $force_print = FALSE ) { |
|
967 | - if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
|
968 | - if ( wp_script_is( 'ee_error_js', 'enqueued' )) { |
|
966 | + private static function _print_scripts($force_print = FALSE) { |
|
967 | + if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) { |
|
968 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
969 | 969 | return; |
970 | - } else if ( wp_script_is( 'ee_error_js', 'registered' )) { |
|
971 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
972 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
973 | - wp_enqueue_script( 'ee_error_js' ); |
|
974 | - wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG )); |
|
970 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
971 | + add_filter('FHEE_load_css', '__return_true'); |
|
972 | + add_filter('FHEE_load_js', '__return_true'); |
|
973 | + wp_enqueue_script('ee_error_js'); |
|
974 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG)); |
|
975 | 975 | } |
976 | 976 | } else { |
977 | 977 | return ' |
978 | 978 | <script> |
979 | 979 | /* <![CDATA[ */ |
980 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
980 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
981 | 981 | /* ]]> */ |
982 | 982 | </script> |
983 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
984 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
985 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
983 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
984 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
985 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
986 | 986 | '; |
987 | 987 | |
988 | 988 | } |
@@ -1016,11 +1016,11 @@ discard block |
||
1016 | 1016 | * @ param string $line |
1017 | 1017 | * @ return string |
1018 | 1018 | */ |
1019 | - public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
|
1020 | - $file = explode( '.', basename( $file )); |
|
1021 | - $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
|
1022 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
1023 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
1019 | + public static function generate_error_code($file = '', $func = '', $line = '') { |
|
1020 | + $file = explode('.', basename($file)); |
|
1021 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1022 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
1023 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
1024 | 1024 | return $error_code; |
1025 | 1025 | } |
1026 | 1026 | |
@@ -1036,36 +1036,36 @@ discard block |
||
1036 | 1036 | * @ param object $ex |
1037 | 1037 | * @ return void |
1038 | 1038 | */ |
1039 | - public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
|
1039 | + public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) { |
|
1040 | 1040 | |
1041 | - if ( ! $ex ) { |
|
1041 | + if ( ! $ex) { |
|
1042 | 1042 | return; |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - if ( ! $time ) { |
|
1045 | + if ( ! $time) { |
|
1046 | 1046 | $time = time(); |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - $exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1050 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
1051 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1052 | - $exception_log .= 'Code: '. $ex['code'] . PHP_EOL; |
|
1053 | - $exception_log .= 'File: '. $ex['file'] . PHP_EOL; |
|
1054 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1055 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1056 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1057 | - $exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1058 | - |
|
1059 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1049 | + $exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1050 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
1051 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
1052 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
1053 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
1054 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
1055 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
1056 | + $exception_log .= $ex['string'].PHP_EOL; |
|
1057 | + $exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1058 | + |
|
1059 | + EE_Registry::instance()->load_helper('File'); |
|
1060 | 1060 | try { |
1061 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ); |
|
1062 | - if ( ! $clear ) { |
|
1061 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file); |
|
1062 | + if ( ! $clear) { |
|
1063 | 1063 | //get existing log file and append new log info |
1064 | - $exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log; |
|
1064 | + $exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log; |
|
1065 | 1065 | } |
1066 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log ); |
|
1067 | - } catch( EE_Error $e ){ |
|
1068 | - EE_Error::add_error( sprintf( __( 'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() )); |
|
1066 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log); |
|
1067 | + } catch (EE_Error $e) { |
|
1068 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage())); |
|
1069 | 1069 | return; |
1070 | 1070 | } |
1071 | 1071 | |
@@ -1089,10 +1089,10 @@ discard block |
||
1089 | 1089 | * @param int $error_type |
1090 | 1090 | * @return void |
1091 | 1091 | */ |
1092 | - public static function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
1093 | - if ( defined('WP_DEBUG') && WP_DEBUG ) { |
|
1092 | + public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
1093 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1094 | 1094 | EE_Registry::instance()->load_helper('Debug_Tools'); |
1095 | - EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $error_type ); |
|
1095 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type); |
|
1096 | 1096 | } |
1097 | 1097 | } |
1098 | 1098 | |
@@ -1112,13 +1112,13 @@ discard block |
||
1112 | 1112 | */ |
1113 | 1113 | function espresso_error_enqueue_scripts() { |
1114 | 1114 | // js for error handling |
1115 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1116 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1115 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1116 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1117 | 1117 | } |
1118 | -if ( is_admin() ) { |
|
1119 | - add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1118 | +if (is_admin()) { |
|
1119 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1120 | 1120 | } else { |
1121 | - add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1121 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 |
@@ -18,52 +18,52 @@ discard block |
||
18 | 18 | |
19 | 19 | |
20 | 20 | /** |
21 | - * name of the file to log exceptions to |
|
22 | - * @access private |
|
23 | - * @var string |
|
24 | - */ |
|
21 | + * name of the file to log exceptions to |
|
22 | + * @access private |
|
23 | + * @var string |
|
24 | + */ |
|
25 | 25 | private static $_exception_log_file = 'espresso_error_log.txt'; |
26 | 26 | |
27 | 27 | /** |
28 | - * the exception |
|
29 | - * @access private |
|
30 | - * @var object |
|
31 | - */ |
|
28 | + * the exception |
|
29 | + * @access private |
|
30 | + * @var object |
|
31 | + */ |
|
32 | 32 | private $_exception; |
33 | 33 | |
34 | 34 | /** |
35 | - * stores details for all exception |
|
36 | - * @access private |
|
37 | - * @var array |
|
38 | - */ |
|
35 | + * stores details for all exception |
|
36 | + * @access private |
|
37 | + * @var array |
|
38 | + */ |
|
39 | 39 | private static $_all_exceptions = array(); |
40 | 40 | |
41 | 41 | /** |
42 | - * tracks number of errors |
|
43 | - * @access private |
|
44 | - * @var int |
|
45 | - */ |
|
42 | + * tracks number of errors |
|
43 | + * @access private |
|
44 | + * @var int |
|
45 | + */ |
|
46 | 46 | private static $_error_count = 0; |
47 | 47 | |
48 | 48 | /** |
49 | - * has JS been loaded ? |
|
50 | - * @access private |
|
51 | - * @var boolean |
|
52 | - */ |
|
49 | + * has JS been loaded ? |
|
50 | + * @access private |
|
51 | + * @var boolean |
|
52 | + */ |
|
53 | 53 | private static $_js_loaded = FALSE; |
54 | 54 | |
55 | 55 | /** |
56 | - * has shutdown action been added ? |
|
57 | - * @access private |
|
58 | - * @var boolean |
|
59 | - */ |
|
56 | + * has shutdown action been added ? |
|
57 | + * @access private |
|
58 | + * @var boolean |
|
59 | + */ |
|
60 | 60 | private static $_action_added = FALSE; |
61 | 61 | |
62 | 62 | /** |
63 | - * has shutdown action been added ? |
|
64 | - * @access private |
|
65 | - * @var boolean |
|
66 | - */ |
|
63 | + * has shutdown action been added ? |
|
64 | + * @access private |
|
65 | + * @var boolean |
|
66 | + */ |
|
67 | 67 | private static $_espresso_notices = array( 'success' => FALSE, 'errors' => FALSE, 'attention' => FALSE ); |
68 | 68 | |
69 | 69 | |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | |
72 | 72 | |
73 | 73 | /** |
74 | - * @override default exception handling |
|
75 | - * @access public |
|
76 | - * @echo string |
|
77 | - */ |
|
74 | + * @override default exception handling |
|
75 | + * @access public |
|
76 | + * @echo string |
|
77 | + */ |
|
78 | 78 | function __construct( $message, $code = 0, Exception $previous = NULL ) { |
79 | 79 | if ( version_compare( phpversion(), '5.3.0', '<' )) { |
80 | 80 | parent::__construct( $message, $code ); |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | |
174 | 174 | |
175 | 175 | /** |
176 | - * fatal_error_handler |
|
177 | - * @access public |
|
178 | - * @return void |
|
179 | - */ |
|
176 | + * fatal_error_handler |
|
177 | + * @access public |
|
178 | + * @return void |
|
179 | + */ |
|
180 | 180 | public static function fatal_error_handler() { |
181 | 181 | $last_error = error_get_last(); |
182 | 182 | if ( $last_error['type'] === E_ERROR ) { |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | |
222 | 222 | |
223 | 223 | /** |
224 | - * _add_actions |
|
225 | - * @access public |
|
226 | - * @return void |
|
227 | - */ |
|
228 | - public function get_error() { |
|
224 | + * _add_actions |
|
225 | + * @access public |
|
226 | + * @return void |
|
227 | + */ |
|
228 | + public function get_error() { |
|
229 | 229 | |
230 | 230 | if( apply_filters( 'FHEE__EE_Error__get_error__show_normal_exceptions', FALSE ) ){ |
231 | 231 | throw $this; |
@@ -255,22 +255,22 @@ discard block |
||
255 | 255 | |
256 | 256 | |
257 | 257 | /** |
258 | - * has_error |
|
259 | - * @access public |
|
260 | - * @return boolean |
|
261 | - */ |
|
262 | - public static function has_error(){ |
|
258 | + * has_error |
|
259 | + * @access public |
|
260 | + * @return boolean |
|
261 | + */ |
|
262 | + public static function has_error(){ |
|
263 | 263 | return self::$_error_count ? TRUE : FALSE; |
264 | 264 | } |
265 | 265 | |
266 | 266 | |
267 | 267 | |
268 | 268 | /** |
269 | - * display_errors |
|
270 | - * @access public |
|
271 | - * @echo string |
|
272 | - */ |
|
273 | - public function display_errors(){ |
|
269 | + * display_errors |
|
270 | + * @access public |
|
271 | + * @echo string |
|
272 | + */ |
|
273 | + public function display_errors(){ |
|
274 | 274 | |
275 | 275 | $trace_details = ''; |
276 | 276 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | // process trace info |
343 | 343 | if ( empty( $ex['trace'] )) { |
344 | 344 | |
345 | - $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' ); |
|
345 | + $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' ); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $function_dsply = ! empty( $function ) ? $function : ' '; |
395 | 395 | $args_dsply = ! empty( $args ) ? '( ' . $args . ' )' : ''; |
396 | 396 | |
397 | - $trace_details .= ' |
|
397 | + $trace_details .= ' |
|
398 | 398 | <tr> |
399 | 399 | <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
400 | 400 | <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | |
407 | 407 | } |
408 | 408 | |
409 | - $trace_details .= ' |
|
409 | + $trace_details .= ' |
|
410 | 410 | </table> |
411 | 411 | </div>'; |
412 | 412 | |
@@ -486,12 +486,12 @@ discard block |
||
486 | 486 | |
487 | 487 | |
488 | 488 | /** |
489 | - * generate string from exception trace args |
|
490 | - * |
|
491 | - * @access private |
|
492 | - * @ param array $arguments |
|
493 | - * @ return string |
|
494 | - */ |
|
489 | + * generate string from exception trace args |
|
490 | + * |
|
491 | + * @access private |
|
492 | + * @ param array $arguments |
|
493 | + * @ return string |
|
494 | + */ |
|
495 | 495 | private function _convert_args_to_string ( $arguments = array(), $array = FALSE ) { |
496 | 496 | |
497 | 497 | $arg_string = ''; |
@@ -535,15 +535,15 @@ discard block |
||
535 | 535 | |
536 | 536 | |
537 | 537 | /** |
538 | - * add error message |
|
539 | - * |
|
540 | - * @access public |
|
541 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev |
|
542 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
543 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
544 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
545 | - * @return void |
|
546 | - */ |
|
538 | + * add error message |
|
539 | + * |
|
540 | + * @access public |
|
541 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev |
|
542 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
543 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
544 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
545 | + * @return void |
|
546 | + */ |
|
547 | 547 | public static function add_error( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
548 | 548 | self::_add_notice ( 'errors', $msg, $file, $func, $line ); |
549 | 549 | self::$_error_count++; |
@@ -554,15 +554,15 @@ discard block |
||
554 | 554 | |
555 | 555 | |
556 | 556 | /** |
557 | - * add success message |
|
558 | - * |
|
559 | - * @access public |
|
560 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev |
|
561 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
562 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
563 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
564 | - * @return void |
|
565 | - */ |
|
557 | + * add success message |
|
558 | + * |
|
559 | + * @access public |
|
560 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev |
|
561 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
562 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
563 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
564 | + * @return void |
|
565 | + */ |
|
566 | 566 | public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
567 | 567 | self::_add_notice ( 'success', $msg, $file, $func, $line ); |
568 | 568 | } |
@@ -572,15 +572,15 @@ discard block |
||
572 | 572 | |
573 | 573 | |
574 | 574 | /** |
575 | - * add attention message |
|
576 | - * |
|
577 | - * @access public |
|
578 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev |
|
579 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
580 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
581 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
582 | - * @return void |
|
583 | - */ |
|
575 | + * add attention message |
|
576 | + * |
|
577 | + * @access public |
|
578 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev |
|
579 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
580 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
581 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
582 | + * @return void |
|
583 | + */ |
|
584 | 584 | public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
585 | 585 | self::_add_notice ( 'attention', $msg, $file, $func, $line ); |
586 | 586 | } |
@@ -590,16 +590,16 @@ discard block |
||
590 | 590 | |
591 | 591 | |
592 | 592 | /** |
593 | - * add success message |
|
594 | - * |
|
595 | - * @access public |
|
596 | - * @param string $type whether the message is for a success or error notification |
|
597 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev |
|
598 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
599 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
600 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
601 | - * @return void |
|
602 | - */ |
|
593 | + * add success message |
|
594 | + * |
|
595 | + * @access public |
|
596 | + * @param string $type whether the message is for a success or error notification |
|
597 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates separate messages for user || dev |
|
598 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
599 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
600 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
601 | + * @return void |
|
602 | + */ |
|
603 | 603 | private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
604 | 604 | if ( empty( $msg )) { |
605 | 605 | EE_Error::doing_it_wrong( |
@@ -643,11 +643,11 @@ discard block |
||
643 | 643 | |
644 | 644 | |
645 | 645 | /** |
646 | - * in some case it may be necessary to overwrite the existing success messages |
|
647 | - * |
|
648 | - * @access public |
|
649 | - * @return void |
|
650 | - */ |
|
646 | + * in some case it may be necessary to overwrite the existing success messages |
|
647 | + * |
|
648 | + * @access public |
|
649 | + * @return void |
|
650 | + */ |
|
651 | 651 | public static function overwrite_success() { |
652 | 652 | self::$_espresso_notices['success'] = FALSE; |
653 | 653 | } |
@@ -657,11 +657,11 @@ discard block |
||
657 | 657 | |
658 | 658 | |
659 | 659 | /** |
660 | - * in some case it may be necessary to overwrite the existing attention messages |
|
661 | - * |
|
662 | - * @access public |
|
663 | - * @return void |
|
664 | - */ |
|
660 | + * in some case it may be necessary to overwrite the existing attention messages |
|
661 | + * |
|
662 | + * @access public |
|
663 | + * @return void |
|
664 | + */ |
|
665 | 665 | public static function overwrite_attention() { |
666 | 666 | self::$_espresso_notices['attention'] = FALSE; |
667 | 667 | } |
@@ -671,11 +671,11 @@ discard block |
||
671 | 671 | |
672 | 672 | |
673 | 673 | /** |
674 | - * in some case it may be necessary to overwrite the existing error messages |
|
675 | - * |
|
676 | - * @access public |
|
677 | - * @return void |
|
678 | - */ |
|
674 | + * in some case it may be necessary to overwrite the existing error messages |
|
675 | + * |
|
676 | + * @access public |
|
677 | + * @return void |
|
678 | + */ |
|
679 | 679 | public static function overwrite_errors() { |
680 | 680 | self::$_espresso_notices['errors'] = FALSE; |
681 | 681 | } |
@@ -683,24 +683,24 @@ discard block |
||
683 | 683 | |
684 | 684 | |
685 | 685 | /** |
686 | - * reset_notices |
|
687 | - * @access private |
|
688 | - * @return void |
|
689 | - */ |
|
686 | + * reset_notices |
|
687 | + * @access private |
|
688 | + * @return void |
|
689 | + */ |
|
690 | 690 | public static function reset_notices(){ |
691 | - self::$_espresso_notices['success'] = FALSE; |
|
692 | - self::$_espresso_notices['attention'] = FALSE; |
|
693 | - self::$_espresso_notices['errors'] = FALSE; |
|
694 | - } |
|
691 | + self::$_espresso_notices['success'] = FALSE; |
|
692 | + self::$_espresso_notices['attention'] = FALSE; |
|
693 | + self::$_espresso_notices['errors'] = FALSE; |
|
694 | + } |
|
695 | 695 | |
696 | 696 | |
697 | 697 | |
698 | 698 | /** |
699 | - * has_errors |
|
700 | - * @access public |
|
701 | - * @return int |
|
702 | - */ |
|
703 | - public static function has_notices(){ |
|
699 | + * has_errors |
|
700 | + * @access public |
|
701 | + * @return int |
|
702 | + */ |
|
703 | + public static function has_notices(){ |
|
704 | 704 | $has_notices = 0; |
705 | 705 | // check for success messages |
706 | 706 | $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
@@ -714,14 +714,14 @@ discard block |
||
714 | 714 | |
715 | 715 | |
716 | 716 | /** |
717 | - * compile all error or success messages into one string |
|
718 | - * |
|
719 | - * @access public |
|
720 | - * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
721 | - * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request - ONLY do this just before redirecting |
|
722 | - * @param boolean $remove_empty whether or not to unset empty messages |
|
723 | - * @return array |
|
724 | - */ |
|
717 | + * compile all error or success messages into one string |
|
718 | + * |
|
719 | + * @access public |
|
720 | + * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
721 | + * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request - ONLY do this just before redirecting |
|
722 | + * @param boolean $remove_empty whether or not to unset empty messages |
|
723 | + * @return array |
|
724 | + */ |
|
725 | 725 | public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
726 | 726 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
727 | 727 | |
@@ -833,14 +833,14 @@ discard block |
||
833 | 833 | |
834 | 834 | |
835 | 835 | /** |
836 | - * add_persistent_admin_notice |
|
837 | - * |
|
838 | - * @access public |
|
839 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
840 | - * @param string $pan_message the message to be stored persistently until dismissed |
|
841 | - * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
842 | - * @return void |
|
843 | - */ |
|
836 | + * add_persistent_admin_notice |
|
837 | + * |
|
838 | + * @access public |
|
839 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
840 | + * @param string $pan_message the message to be stored persistently until dismissed |
|
841 | + * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
842 | + * @return void |
|
843 | + */ |
|
844 | 844 | public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
845 | 845 | if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
846 | 846 | $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
@@ -904,9 +904,9 @@ discard block |
||
904 | 904 | * display_persistent_admin_notices |
905 | 905 | * |
906 | 906 | * @access public |
907 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
908 | - * @param string $pan_name the message to be stored persistently until dismissed |
|
909 | - * @param string $return_url URL to go back to aftger nag notice is dismissed |
|
907 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
908 | + * @param string $pan_name the message to be stored persistently until dismissed |
|
909 | + * @param string $return_url URL to go back to aftger nag notice is dismissed |
|
910 | 910 | * @return string |
911 | 911 | */ |
912 | 912 | public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
@@ -995,11 +995,11 @@ discard block |
||
995 | 995 | |
996 | 996 | |
997 | 997 | /** |
998 | - * enqueue_error_scripts |
|
999 | - * |
|
1000 | - * @access public |
|
1001 | - * @return void |
|
1002 | - */ |
|
998 | + * enqueue_error_scripts |
|
999 | + * |
|
1000 | + * @access public |
|
1001 | + * @return void |
|
1002 | + */ |
|
1003 | 1003 | public static function enqueue_error_scripts() { |
1004 | 1004 | self::_print_scripts(); |
1005 | 1005 | } |
@@ -1007,15 +1007,15 @@ discard block |
||
1007 | 1007 | |
1008 | 1008 | |
1009 | 1009 | /** |
1010 | - * create error code from filepath, function name, |
|
1011 | - * and line number where exception or error was thrown |
|
1012 | - * |
|
1013 | - * @access public |
|
1014 | - * @ param string $file |
|
1015 | - * @ param string $func |
|
1016 | - * @ param string $line |
|
1017 | - * @ return string |
|
1018 | - */ |
|
1010 | + * create error code from filepath, function name, |
|
1011 | + * and line number where exception or error was thrown |
|
1012 | + * |
|
1013 | + * @access public |
|
1014 | + * @ param string $file |
|
1015 | + * @ param string $func |
|
1016 | + * @ param string $line |
|
1017 | + * @ return string |
|
1018 | + */ |
|
1019 | 1019 | public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
1020 | 1020 | $file = explode( '.', basename( $file )); |
1021 | 1021 | $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
@@ -1029,13 +1029,13 @@ discard block |
||
1029 | 1029 | |
1030 | 1030 | |
1031 | 1031 | /** |
1032 | - * write exception details to log file |
|
1033 | - * |
|
1034 | - * @access public |
|
1035 | - * @ param timestamp $time |
|
1036 | - * @ param object $ex |
|
1037 | - * @ return void |
|
1038 | - */ |
|
1032 | + * write exception details to log file |
|
1033 | + * |
|
1034 | + * @access public |
|
1035 | + * @ param timestamp $time |
|
1036 | + * @ param object $ex |
|
1037 | + * @ return void |
|
1038 | + */ |
|
1039 | 1039 | public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
1040 | 1040 | |
1041 | 1041 | if ( ! $ex ) { |
@@ -184,7 +184,7 @@ |
||
184 | 184 | * returns TRUE if M-Mode is engaged and the current request is not for the admin |
185 | 185 | * |
186 | 186 | * @access public |
187 | - * @return string |
|
187 | + * @return boolean |
|
188 | 188 | */ |
189 | 189 | public static function disable_frontend_for_maintenance() { |
190 | 190 | return ! is_admin() && EE_Maintenance_Mode::instance()->level() ? TRUE : FALSE; |
@@ -48,10 +48,10 @@ |
||
48 | 48 | */ |
49 | 49 | const option_name_maintenance_mode = 'ee_maintenance_mode'; |
50 | 50 | /** |
51 | - * EE_Maintenance_Mode Object |
|
52 | - * @var EE_Maintenance_Mode $_instance |
|
53 | - * @access private |
|
54 | - */ |
|
51 | + * EE_Maintenance_Mode Object |
|
52 | + * @var EE_Maintenance_Mode $_instance |
|
53 | + * @access private |
|
54 | + */ |
|
55 | 55 | private static $_instance = NULL; |
56 | 56 | |
57 | 57 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | current_user_can('administrator') && //when the user is an admin |
142 | 142 | $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1 |
143 | 143 | $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
144 | - }else{ |
|
144 | + } else{ |
|
145 | 145 | $maintenance_mode_level = $real_maintenance_mode_level; |
146 | 146 | } |
147 | 147 | return $maintenance_mode_level; |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
157 | 157 | update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
158 | 158 | return true; |
159 | - }elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
159 | + } elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
160 | 160 | //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
161 | 161 | //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
162 | 162 | update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance ); |
163 | 163 | return false; |
164 | - }else{ |
|
164 | + } else{ |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public static function instance() { |
75 | 75 | // check if class object is instantiated |
76 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Maintenance_Mode )) { |
|
76 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Maintenance_Mode)) { |
|
77 | 77 | self::$_instance = new self(); |
78 | 78 | } |
79 | 79 | return self::$_instance; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode) |
84 | 84 | * @return EE_Maintenance_Mode |
85 | 85 | */ |
86 | - public static function reset(){ |
|
86 | + public static function reset() { |
|
87 | 87 | self::instance()->set_maintenance_mode_if_db_old(); |
88 | 88 | return self::instance(); |
89 | 89 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | */ |
99 | 99 | private function __construct() { |
100 | 100 | // if M-Mode level 2 is engaged, we still need basic assets loaded |
101 | - add_action( 'wp_enqueue_scripts', array( $this, 'load_assets_required_for_m_mode' )); |
|
101 | + add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode')); |
|
102 | 102 | // shut 'er down down for maintenance ? |
103 | - add_filter( 'the_content', array( $this, 'the_content' ), 999 ); |
|
103 | + add_filter('the_content', array($this, 'the_content'), 999); |
|
104 | 104 | // add powered by EE msg |
105 | - add_action( 'shutdown', array( $this, 'display_maintenance_mode_notice' ), 10 ); |
|
105 | + add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * retrieves the maintenance mode option value from the db |
113 | 113 | * @return int |
114 | 114 | */ |
115 | - public function real_level(){ |
|
116 | - return get_option( self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance ); |
|
115 | + public function real_level() { |
|
116 | + return get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * thinks their tables are present and up-to-date). |
122 | 122 | * @return boolean |
123 | 123 | */ |
124 | - public function models_can_query(){ |
|
124 | + public function models_can_query() { |
|
125 | 125 | return $this->real_level() != EE_Maintenance_Mode::level_2_complete_maintenance; |
126 | 126 | } |
127 | 127 | |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode |
135 | 135 | * @return int |
136 | 136 | */ |
137 | - public function level(){ |
|
137 | + public function level() { |
|
138 | 138 | $real_maintenance_mode_level = $this->real_level(); |
139 | 139 | //if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend |
140 | - if( ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
140 | + if (( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
141 | 141 | current_user_can('administrator') && //when the user is an admin |
142 | - $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1 |
|
142 | + $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance) {//and we're in level 1 |
|
143 | 143 | $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
144 | - }else{ |
|
144 | + } else { |
|
145 | 145 | $maintenance_mode_level = $real_maintenance_mode_level; |
146 | 146 | } |
147 | 147 | return $maintenance_mode_level; |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | * Determines if we need to put EE in maintenance mode because the database needs updating |
152 | 152 | * @return boolean true if DB is old and maintenance mode was triggered; false otherwise |
153 | 153 | */ |
154 | - public function set_maintenance_mode_if_db_old(){ |
|
155 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
156 | - if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
|
154 | + public function set_maintenance_mode_if_db_old() { |
|
155 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
156 | + if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
157 | 157 | update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
158 | 158 | return true; |
159 | - }elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
159 | + }elseif ($this->level() == self::level_2_complete_maintenance) { |
|
160 | 160 | //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
161 | 161 | //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
162 | - update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance ); |
|
162 | + update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance); |
|
163 | 163 | return false; |
164 | - }else{ |
|
164 | + } else { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @param int $level |
172 | 172 | * @return void |
173 | 173 | */ |
174 | - public function set_maintenance_level($level){ |
|
175 | - do_action( 'AHEE__EE_Maintenance_Mode__set_maintenance_level', $level ); |
|
174 | + public function set_maintenance_level($level) { |
|
175 | + do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
|
176 | 176 | update_option(self::option_name_maintenance_mode, intval($level)); |
177 | 177 | } |
178 | 178 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @return string |
200 | 200 | */ |
201 | 201 | public function load_assets_required_for_m_mode() { |
202 | - if ( $this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is( 'espresso_core', 'enqueued' )) { |
|
203 | - wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
202 | + if ($this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is('espresso_core', 'enqueued')) { |
|
203 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
204 | 204 | wp_enqueue_style('espresso_default'); |
205 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
206 | - wp_enqueue_script( 'espresso_core' ); |
|
205 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
206 | + wp_enqueue_script('espresso_core'); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * @param string $template_path |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public static function template_include( $template_path ) { |
|
222 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
223 | - $template_located = EEH_Template::locate_template( EE_TEMPLATES . 'maintenance_mode.template.php', FALSE, FALSE ); |
|
221 | + public static function template_include($template_path) { |
|
222 | + EE_Registry::instance()->load_helper('Template'); |
|
223 | + $template_located = EEH_Template::locate_template(EE_TEMPLATES.'maintenance_mode.template.php', FALSE, FALSE); |
|
224 | 224 | return $template_located ? $template_located : $template_path; |
225 | 225 | } |
226 | 226 | |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * @param string $the_content |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public function the_content( $the_content ) { |
|
238 | + public function the_content($the_content) { |
|
239 | 239 | // check if M-mode is engaged and for EE shortcode |
240 | - if ( $this->level() && strpos( $the_content, '[ESPRESSO_' )) { |
|
240 | + if ($this->level() && strpos($the_content, '[ESPRESSO_')) { |
|
241 | 241 | // this can eventually be moved to a template, or edited via admin. But for now... |
242 | 242 | $the_content = sprintf( |
243 | - __( '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso' ), |
|
243 | + __('%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso'), |
|
244 | 244 | '<h2>', |
245 | 245 | '</h2><p>', |
246 | 246 | '</p>' |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | // check if M-mode is engaged and for EE shortcode |
265 | 265 | if ( |
266 | 266 | $this->real_level() && |
267 | - current_user_can( 'administrator' ) && |
|
267 | + current_user_can('administrator') && |
|
268 | 268 | ! is_admin() && |
269 | - ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
269 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
270 | 270 | && EE_Registry::instance()->REQ->is_espresso_page() |
271 | 271 | ) { |
272 | 272 | printf( |
273 | - __( '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso' ), |
|
273 | + __('%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso'), |
|
274 | 274 | '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
275 | 275 | '">×</a><p>', |
276 | - ' » <a href="' . add_query_arg( array( 'page' => 'espresso_maintenance_settings' ), admin_url( 'admin.php' )) . '">', |
|
276 | + ' » <a href="'.add_query_arg(array('page' => 'espresso_maintenance_settings'), admin_url('admin.php')).'">', |
|
277 | 277 | '</a></p></div>' |
278 | 278 | ); |
279 | 279 | } |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @ return void |
292 | 292 | */ |
293 | 293 | final function __destruct() {} |
294 | - final function __call($a,$b) {} |
|
294 | + final function __call($a, $b) {} |
|
295 | 295 | final function __get($a) {} |
296 | - final function __set($a,$b) {} |
|
296 | + final function __set($a, $b) {} |
|
297 | 297 | final function __isset($a) {} |
298 | 298 | final function __unset($a) {} |
299 | 299 | final function __sleep() { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | final function __invoke() {} |
305 | 305 | final function __set_state() {} |
306 | 306 | final function __clone() {} |
307 | - final static function __callStatic($a,$b) {} |
|
307 | + final static function __callStatic($a, $b) {} |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | // End of file EE_Maintenance_Mode.core.php |
@@ -214,6 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | /** |
216 | 216 | * @param mixed string | EED_Module $module |
217 | + * @param boolean|string $module |
|
217 | 218 | */ |
218 | 219 | public function add_module( $module ) { |
219 | 220 | if ( $module instanceof EED_Module ) { |
@@ -245,7 +246,7 @@ discard block |
||
245 | 246 | * @param string $class_name - simple class name ie: session |
246 | 247 | * @param mixed $arguments |
247 | 248 | * @param bool $load_only |
248 | - * @return mixed |
|
249 | + * @return boolean |
|
249 | 250 | */ |
250 | 251 | public function load_core ( $class_name, $arguments = array(), $load_only = FALSE ) { |
251 | 252 | $core_paths = apply_filters( |
@@ -269,7 +270,7 @@ discard block |
||
269 | 270 | * @access public |
270 | 271 | * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0 |
271 | 272 | * @param mixed $arguments |
272 | - * @return EE_Data_Migration_Script_Base |
|
273 | + * @return boolean |
|
273 | 274 | */ |
274 | 275 | public function load_dms ( $class_name, $arguments = array() ) { |
275 | 276 | // retrieve instantiated class |
@@ -286,7 +287,7 @@ discard block |
||
286 | 287 | * @param bool $from_db - some classes are instantiated from the db and thus call a different method to instantiate |
287 | 288 | * @param bool $cache if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop) |
288 | 289 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
289 | - * @return EE_Base_Class |
|
290 | + * @return boolean |
|
290 | 291 | */ |
291 | 292 | public function load_class ( $class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
292 | 293 | $paths = apply_filters('FHEE__EE_Registry__load_class__paths',array( |
@@ -307,7 +308,7 @@ discard block |
||
307 | 308 | * @param string $class_name - simple class name ie: price |
308 | 309 | * @param mixed $arguments |
309 | 310 | * @param bool $load_only |
310 | - * @return EEH_Base |
|
311 | + * @return boolean |
|
311 | 312 | */ |
312 | 313 | public function load_helper ( $class_name, $arguments = array(), $load_only = TRUE ) { |
313 | 314 | $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS ) ); |
@@ -324,7 +325,7 @@ discard block |
||
324 | 325 | * @param string $class_name - simple class name ie: session |
325 | 326 | * @param mixed $arguments |
326 | 327 | * @param bool $load_only |
327 | - * @return mixed |
|
328 | + * @return boolean |
|
328 | 329 | */ |
329 | 330 | public function load_lib ( $class_name, $arguments = array(), $load_only = FALSE ) { |
330 | 331 | $paths = array( |
@@ -346,7 +347,7 @@ discard block |
||
346 | 347 | * @param string $class_name - simple class name ie: price |
347 | 348 | * @param mixed $arguments |
348 | 349 | * @param bool $load_only |
349 | - * @return EEM_Base |
|
350 | + * @return boolean |
|
350 | 351 | */ |
351 | 352 | public function load_model ( $class_name, $arguments = array(), $load_only = FALSE ) { |
352 | 353 | $paths = apply_filters('FHEE__EE_Registry__load_model__paths',array( |
@@ -365,7 +366,7 @@ discard block |
||
365 | 366 | * @param string $class_name - simple class name ie: price |
366 | 367 | * @param mixed $arguments |
367 | 368 | * @param bool $load_only |
368 | - * @return mixed |
|
369 | + * @return boolean |
|
369 | 370 | */ |
370 | 371 | public function load_model_class ( $class_name, $arguments = array(), $load_only = TRUE ) { |
371 | 372 | $paths = array( |
@@ -401,7 +402,7 @@ discard block |
||
401 | 402 | * @param string $type - file type - core? class? helper? model? |
402 | 403 | * @param mixed $arguments |
403 | 404 | * @param bool $load_only |
404 | - * @return mixed |
|
405 | + * @return boolean |
|
405 | 406 | */ |
406 | 407 | public function load_file ( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE ) { |
407 | 408 | // retrieve instantiated class |
@@ -418,7 +419,7 @@ discard block |
||
418 | 419 | * @param string $type - file type - core? class? helper? model? |
419 | 420 | * @param mixed $arguments |
420 | 421 | * @param bool $load_only |
421 | - * @return EE_Addon |
|
422 | + * @return boolean |
|
422 | 423 | */ |
423 | 424 | public function load_addon ( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE ) { |
424 | 425 | // retrieve instantiated class |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public static function instance() { |
158 | 158 | // check if class object is instantiated |
159 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Registry )) { |
|
159 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Registry)) { |
|
160 | 160 | self::$_instance = new self(); |
161 | 161 | } |
162 | 162 | return self::$_instance; |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * @return EE_Registry |
172 | 172 | */ |
173 | 173 | private function __construct() { |
174 | - $this->load_core( 'Base' ); |
|
174 | + $this->load_core('Base'); |
|
175 | 175 | // class library |
176 | 176 | $this->LIB = new StdClass(); |
177 | 177 | $this->addons = new StdClass(); |
178 | 178 | $this->modules = new StdClass(); |
179 | 179 | $this->shortcodes = new StdClass(); |
180 | 180 | $this->widgets = new StdClass(); |
181 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' )); |
|
181 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function init() { |
193 | 193 | // Get current page protocol |
194 | - $protocol = isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://'; |
|
194 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
195 | 195 | // Output admin-ajax.php URL with same protocol as current page |
196 | - self::$i18n_js_strings['ajax_url'] = admin_url( 'admin-ajax.php', $protocol ); |
|
197 | - self::$i18n_js_strings['wp_debug'] = defined( 'WP_DEBUG' ) ? WP_DEBUG : FALSE; |
|
196 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
197 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : FALSE; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | * @return string |
206 | 206 | */ |
207 | 207 | public static function localize_i18n_js_strings() { |
208 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
209 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
210 | - if ( is_scalar( $value ) ) { |
|
211 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
208 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
209 | + foreach ($i18n_js_strings as $key => $value) { |
|
210 | + if (is_scalar($value)) { |
|
211 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
215 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | /** |
221 | 221 | * @param mixed string | EED_Module $module |
222 | 222 | */ |
223 | - public function add_module( $module ) { |
|
224 | - if ( $module instanceof EED_Module ) { |
|
225 | - $module_class = get_class( $module ); |
|
223 | + public function add_module($module) { |
|
224 | + if ($module instanceof EED_Module) { |
|
225 | + $module_class = get_class($module); |
|
226 | 226 | $this->modules->{$module_class} = $module; |
227 | 227 | } else { |
228 | - if ( ! class_exists( 'EE_Module_Request_Router' )) { |
|
229 | - $this->load_core( 'Module_Request_Router' ); |
|
228 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
229 | + $this->load_core('Module_Request_Router'); |
|
230 | 230 | } |
231 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
231 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | * @param string $module_name |
239 | 239 | * @return mixed EED_Module | NULL |
240 | 240 | */ |
241 | - public function get_module( $module_name = '' ) { |
|
242 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : NULL; |
|
241 | + public function get_module($module_name = '') { |
|
242 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : NULL; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -252,18 +252,18 @@ discard block |
||
252 | 252 | * @param bool $load_only |
253 | 253 | * @return mixed |
254 | 254 | */ |
255 | - public function load_core ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
255 | + public function load_core($class_name, $arguments = array(), $load_only = FALSE) { |
|
256 | 256 | $core_paths = apply_filters( |
257 | 257 | 'FHEE__EE_Registry__load_core__core_paths', |
258 | 258 | array( |
259 | 259 | EE_CORE, |
260 | 260 | EE_ADMIN, |
261 | 261 | EE_CPTS, |
262 | - EE_CORE . 'data_migration_scripts' . DS |
|
262 | + EE_CORE.'data_migration_scripts'.DS |
|
263 | 263 | ) |
264 | 264 | ); |
265 | 265 | // retrieve instantiated class |
266 | - return $this->_load( $core_paths, 'EE_' , $class_name, 'core', $arguments, FALSE, TRUE, $load_only ); |
|
266 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, FALSE, TRUE, $load_only); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param mixed $arguments |
277 | 277 | * @return EE_Data_Migration_Script_Base |
278 | 278 | */ |
279 | - public function load_dms ( $class_name, $arguments = array() ) { |
|
279 | + public function load_dms($class_name, $arguments = array()) { |
|
280 | 280 | // retrieve instantiated class |
281 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_' , $class_name, 'dms', $arguments, FALSE, FALSE, FALSE ); |
|
281 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, FALSE, FALSE, FALSE); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
294 | 294 | * @return EE_Base_Class |
295 | 295 | */ |
296 | - public function load_class ( $class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
|
297 | - $paths = apply_filters('FHEE__EE_Registry__load_class__paths',array( |
|
296 | + public function load_class($class_name, $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE) { |
|
297 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
298 | 298 | EE_CORE, |
299 | 299 | EE_CLASSES, |
300 | 300 | EE_BUSINESS |
301 | 301 | )); |
302 | 302 | // retrieve instantiated class |
303 | - return $this->_load( $paths, 'EE_' , $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
303 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | * @param bool $load_only |
315 | 315 | * @return EEH_Base |
316 | 316 | */ |
317 | - public function load_helper ( $class_name, $arguments = array(), $load_only = TRUE ) { |
|
318 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS ) ); |
|
317 | + public function load_helper($class_name, $arguments = array(), $load_only = TRUE) { |
|
318 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
319 | 319 | // retrieve instantiated class |
320 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, FALSE, TRUE, $load_only ); |
|
320 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, FALSE, TRUE, $load_only); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | |
@@ -331,16 +331,16 @@ discard block |
||
331 | 331 | * @param bool $load_only |
332 | 332 | * @return mixed |
333 | 333 | */ |
334 | - public function load_lib ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
334 | + public function load_lib($class_name, $arguments = array(), $load_only = FALSE) { |
|
335 | 335 | $paths = array( |
336 | 336 | EE_LIBRARIES, |
337 | - EE_LIBRARIES . 'messages' . DS, |
|
338 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
339 | - EE_LIBRARIES . 'qtips' . DS, |
|
340 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
337 | + EE_LIBRARIES.'messages'.DS, |
|
338 | + EE_LIBRARIES.'shortcodes'.DS, |
|
339 | + EE_LIBRARIES.'qtips'.DS, |
|
340 | + EE_LIBRARIES.'payment_methods'.DS, |
|
341 | 341 | ); |
342 | 342 | // retrieve instantiated class |
343 | - return $this->_load( $paths, 'EE_' , $class_name, 'lib', $arguments, FALSE, TRUE, $load_only ); |
|
343 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, FALSE, TRUE, $load_only); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | * @param bool $load_only |
354 | 354 | * @return EEM_Base |
355 | 355 | */ |
356 | - public function load_model ( $class_name, $arguments = array(), $load_only = FALSE ) { |
|
357 | - $paths = apply_filters('FHEE__EE_Registry__load_model__paths',array( |
|
356 | + public function load_model($class_name, $arguments = array(), $load_only = FALSE) { |
|
357 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
358 | 358 | EE_MODELS, |
359 | 359 | EE_CORE |
360 | 360 | )); |
361 | 361 | // retrieve instantiated class |
362 | - return $this->_load( $paths, 'EEM_' , $class_name, 'model', $arguments, FALSE, TRUE, $load_only ); |
|
362 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, FALSE, TRUE, $load_only); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -372,15 +372,15 @@ discard block |
||
372 | 372 | * @param bool $load_only |
373 | 373 | * @return mixed |
374 | 374 | */ |
375 | - public function load_model_class ( $class_name, $arguments = array(), $load_only = TRUE ) { |
|
375 | + public function load_model_class($class_name, $arguments = array(), $load_only = TRUE) { |
|
376 | 376 | $paths = array( |
377 | - EE_MODELS . 'fields' . DS, |
|
378 | - EE_MODELS . 'helpers' . DS, |
|
379 | - EE_MODELS . 'relations' . DS, |
|
380 | - EE_MODELS . 'strategies' . DS |
|
377 | + EE_MODELS.'fields'.DS, |
|
378 | + EE_MODELS.'helpers'.DS, |
|
379 | + EE_MODELS.'relations'.DS, |
|
380 | + EE_MODELS.'strategies'.DS |
|
381 | 381 | ); |
382 | 382 | // retrieve instantiated class |
383 | - return $this->_load( $paths, 'EE_' , $class_name, '', $arguments, FALSE, TRUE, $load_only ); |
|
383 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, FALSE, TRUE, $load_only); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
393 | 393 | * @return boolean |
394 | 394 | */ |
395 | - public function is_model_name( $model_name ){ |
|
396 | - return isset( $this->models[ $model_name ] ) ? TRUE : FALSE; |
|
395 | + public function is_model_name($model_name) { |
|
396 | + return isset($this->models[$model_name]) ? TRUE : FALSE; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -408,9 +408,9 @@ discard block |
||
408 | 408 | * @param bool $load_only |
409 | 409 | * @return mixed |
410 | 410 | */ |
411 | - public function load_file ( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE ) { |
|
411 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = TRUE) { |
|
412 | 412 | // retrieve instantiated class |
413 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, FALSE, TRUE, $load_only ); |
|
413 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, FALSE, TRUE, $load_only); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | * @param bool $load_only |
426 | 426 | * @return EE_Addon |
427 | 427 | */ |
428 | - public function load_addon ( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE ) { |
|
428 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = FALSE) { |
|
429 | 429 | // retrieve instantiated class |
430 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, FALSE, TRUE, $load_only ); |
|
430 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, FALSE, TRUE, $load_only); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -445,15 +445,15 @@ discard block |
||
445 | 445 | * @internal param string $file_path - file path including file name |
446 | 446 | * @return bool | object |
447 | 447 | */ |
448 | - private function _load ( $file_paths = array(), $class_prefix = 'EE_', $class_name = FALSE, $type = 'class', $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE ) { |
|
448 | + private function _load($file_paths = array(), $class_prefix = 'EE_', $class_name = FALSE, $type = 'class', $arguments = array(), $from_db = FALSE, $cache = TRUE, $load_only = FALSE) { |
|
449 | 449 | // strip php file extension |
450 | - $class_name = str_replace( '.php', '', trim( $class_name )); |
|
450 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
451 | 451 | // does the class have a prefix ? |
452 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
452 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
453 | 453 | // make sure $class_prefix is uppercase |
454 | - $class_prefix = strtoupper( trim( $class_prefix )); |
|
454 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
455 | 455 | // add class prefix ONCE!!! |
456 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
456 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | $class_abbreviations = array( |
@@ -466,56 +466,56 @@ discard block |
||
466 | 466 | ); |
467 | 467 | |
468 | 468 | // check if class has already been loaded, and return it if it has been |
469 | - if ( isset( $class_abbreviations[ $class_name ] ) && ! is_null( $this->$class_abbreviations[ $class_name ] )) { |
|
470 | - return $this->$class_abbreviations[ $class_name ]; |
|
471 | - } else if ( isset ( $this->{$class_name} )) { |
|
469 | + if (isset($class_abbreviations[$class_name]) && ! is_null($this->$class_abbreviations[$class_name])) { |
|
470 | + return $this->$class_abbreviations[$class_name]; |
|
471 | + } else if (isset ($this->{$class_name} )) { |
|
472 | 472 | return $this->{$class_name}; |
473 | - } else if ( isset ( $this->LIB->$class_name )) { |
|
473 | + } else if (isset ($this->LIB->$class_name)) { |
|
474 | 474 | return $this->LIB->$class_name; |
475 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->$class_name )) { |
|
475 | + } else if ($class_prefix == 'addon' && isset ($this->addons->$class_name)) { |
|
476 | 476 | return $this->addons->$class_name; |
477 | 477 | } |
478 | 478 | |
479 | 479 | // assume all paths lead nowhere |
480 | 480 | $path = FALSE; |
481 | 481 | // make sure $file_paths is an array |
482 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
482 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
483 | 483 | // cycle thru paths |
484 | - foreach ( $file_paths as $key => $file_path ) { |
|
484 | + foreach ($file_paths as $key => $file_path) { |
|
485 | 485 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
486 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
486 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
487 | 487 | // prep file type |
488 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
488 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
489 | 489 | // build full file path |
490 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
490 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
491 | 491 | //does the file exist and can be read ? |
492 | - if ( is_readable( $file_paths[ $key ] )) { |
|
493 | - $path = $file_paths[ $key ]; |
|
492 | + if (is_readable($file_paths[$key])) { |
|
493 | + $path = $file_paths[$key]; |
|
494 | 494 | break; |
495 | 495 | } |
496 | 496 | } |
497 | 497 | // don't give up! you gotta... |
498 | 498 | try { |
499 | 499 | //does the file exist and can it be read ? |
500 | - if ( ! $path ) { |
|
500 | + if ( ! $path) { |
|
501 | 501 | // so sorry, can't find the file |
502 | - throw new EE_Error ( |
|
503 | - sprintf ( |
|
504 | - __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s','event_espresso'), |
|
505 | - trim( $type, '.' ), |
|
502 | + throw new EE_Error( |
|
503 | + sprintf( |
|
504 | + __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'), |
|
505 | + trim($type, '.'), |
|
506 | 506 | $class_name, |
507 | - '<br />' . implode( ',<br />', $file_paths ) |
|
507 | + '<br />'.implode(',<br />', $file_paths) |
|
508 | 508 | ) |
509 | 509 | ); |
510 | 510 | } |
511 | 511 | // get the file |
512 | - require_once( $path ); |
|
512 | + require_once($path); |
|
513 | 513 | // if the class isn't already declared somewhere |
514 | - if ( class_exists( $class_name, FALSE ) === FALSE ) { |
|
514 | + if (class_exists($class_name, FALSE) === FALSE) { |
|
515 | 515 | // so sorry, not a class |
516 | 516 | throw new EE_Error( |
517 | 517 | sprintf( |
518 | - __('The %s file %s does not appear to contain the %s Class.','event_espresso'), |
|
518 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
519 | 519 | $type, |
520 | 520 | $path, |
521 | 521 | $class_name |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | ); |
524 | 524 | } |
525 | 525 | |
526 | - } catch ( EE_Error $e ) { |
|
526 | + } catch (EE_Error $e) { |
|
527 | 527 | $e->get_error(); |
528 | 528 | } |
529 | 529 | |
@@ -531,38 +531,38 @@ discard block |
||
531 | 531 | // don't give up! you gotta... |
532 | 532 | try { |
533 | 533 | // create reflection |
534 | - $reflector = new ReflectionClass( $class_name ); |
|
534 | + $reflector = new ReflectionClass($class_name); |
|
535 | 535 | // instantiate the class and add to the LIB array for tracking |
536 | 536 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
537 | - if ( $reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only ) { |
|
537 | + if ($reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only) { |
|
538 | 538 | // $instantiation_mode = 0; |
539 | 539 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
540 | 540 | return TRUE; |
541 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
541 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
542 | 542 | // $instantiation_mode = 1; |
543 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
544 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
543 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
544 | + } else if (method_exists($class_name, 'new_instance')) { |
|
545 | 545 | // $instantiation_mode = 2; |
546 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
547 | - } else if ( method_exists( $class_name, 'instance' )) { |
|
546 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
547 | + } else if (method_exists($class_name, 'instance')) { |
|
548 | 548 | // $instantiation_mode = 3; |
549 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
550 | - } else if ( $reflector->isInstantiable() ) { |
|
549 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
550 | + } else if ($reflector->isInstantiable()) { |
|
551 | 551 | // $instantiation_mode = 4; |
552 | - $class_obj = $reflector->newInstance( $arguments ); |
|
553 | - } else if ( ! $load_only ) { |
|
552 | + $class_obj = $reflector->newInstance($arguments); |
|
553 | + } else if ( ! $load_only) { |
|
554 | 554 | // heh ? something's not right ! |
555 | 555 | // $instantiation_mode = 5; |
556 | 556 | throw new EE_Error( |
557 | 557 | sprintf( |
558 | - __('The %s file %s could not be instantiated.','event_espresso'), |
|
558 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
559 | 559 | $type, |
560 | 560 | $class_name |
561 | 561 | ) |
562 | 562 | ); |
563 | 563 | } |
564 | 564 | |
565 | - } catch ( EE_Error $e ) { |
|
565 | + } catch (EE_Error $e) { |
|
566 | 566 | $e->get_error(); |
567 | 567 | } |
568 | 568 | |
@@ -574,15 +574,15 @@ discard block |
||
574 | 574 | // EEH_Debug_Tools::printr( $class_obj, '$class_obj <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
575 | 575 | |
576 | 576 | |
577 | - if ( isset( $class_obj )) { |
|
577 | + if (isset($class_obj)) { |
|
578 | 578 | // return newly instantiated class |
579 | - if ( isset( $class_abbreviations[ $class_name ] )) { |
|
580 | - $this->$class_abbreviations[ $class_name ] = $class_obj; |
|
581 | - } else if ( EEH_Class_Tools::has_property( $this, $class_name )) { |
|
579 | + if (isset($class_abbreviations[$class_name])) { |
|
580 | + $this->$class_abbreviations[$class_name] = $class_obj; |
|
581 | + } else if (EEH_Class_Tools::has_property($this, $class_name)) { |
|
582 | 582 | $this->{$class_name} = $class_obj; |
583 | - } else if ( $class_prefix == 'addon' && $cache ) { |
|
583 | + } else if ($class_prefix == 'addon' && $cache) { |
|
584 | 584 | $this->addons->$class_name = $class_obj; |
585 | - } else if ( !$from_db && $cache ) { |
|
585 | + } else if ( ! $from_db && $cache) { |
|
586 | 586 | $this->LIB->$class_name = $class_obj; |
587 | 587 | } |
588 | 588 | return $class_obj; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @param $a |
608 | 608 | * @param $b |
609 | 609 | */ |
610 | - final function __call($a,$b) {} |
|
610 | + final function __call($a, $b) {} |
|
611 | 611 | |
612 | 612 | |
613 | 613 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * @param $a |
623 | 623 | * @param $b |
624 | 624 | */ |
625 | - final function __set($a,$b) {} |
|
625 | + final function __set($a, $b) {} |
|
626 | 626 | |
627 | 627 | |
628 | 628 | |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * @param $a |
663 | 663 | * @param $b |
664 | 664 | */ |
665 | - final static function __callStatic($a,$b) {} |
|
665 | + final static function __callStatic($a, $b) {} |
|
666 | 666 | |
667 | 667 | /** |
668 | 668 | * Gets the addon by its name/slug (not classname. For that, just |
@@ -670,9 +670,9 @@ discard block |
||
670 | 670 | * @param string $name |
671 | 671 | * @return EE_Addon |
672 | 672 | */ |
673 | - public function get_addon_by_name( $name ){ |
|
674 | - foreach($this->addons as $addon){ |
|
675 | - if( $addon->name() == $name){ |
|
673 | + public function get_addon_by_name($name) { |
|
674 | + foreach ($this->addons as $addon) { |
|
675 | + if ($addon->name() == $name) { |
|
676 | 676 | return $addon; |
677 | 677 | } |
678 | 678 | } |
@@ -683,10 +683,10 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return EE_Addon[] where the KEYS are the addon's name() |
685 | 685 | */ |
686 | - public function get_addons_by_name(){ |
|
686 | + public function get_addons_by_name() { |
|
687 | 687 | $addons = array(); |
688 | - foreach($this->addons as $addon){ |
|
689 | - $addons[ $addon->name() ] = $addon; |
|
688 | + foreach ($this->addons as $addon) { |
|
689 | + $addons[$addon->name()] = $addon; |
|
690 | 690 | } |
691 | 691 | return $addons; |
692 | 692 | } |
@@ -701,14 +701,14 @@ discard block |
||
701 | 701 | * @return EEM_Base |
702 | 702 | * @throws EE_Error |
703 | 703 | */ |
704 | - public function reset_model( $model_name ){ |
|
705 | - $model = $this->load_model( $model_name ); |
|
706 | - $model_class_name = get_class( $model ); |
|
704 | + public function reset_model($model_name) { |
|
705 | + $model = $this->load_model($model_name); |
|
706 | + $model_class_name = get_class($model); |
|
707 | 707 | //get that model reset it and make sure we nuke the old reference to it |
708 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
708 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
709 | 709 | $this->LIB->$model_class_name = $model::reset(); |
710 | - }else{ |
|
711 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
710 | + } else { |
|
711 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
712 | 712 | } |
713 | 713 | return $this->LIB->$model_class_name; |
714 | 714 | } |
@@ -724,15 +724,15 @@ discard block |
||
724 | 724 | * currently reinstantiate the singletons at the moment) |
725 | 725 | * @return EE_Registry |
726 | 726 | */ |
727 | - public static function reset( $hard = FALSE, $reinstantiate = TRUE ){ |
|
727 | + public static function reset($hard = FALSE, $reinstantiate = TRUE) { |
|
728 | 728 | $instance = self::instance(); |
729 | 729 | $instance->load_helper('Activation'); |
730 | 730 | EEH_Activation::reset(); |
731 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
731 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
732 | 732 | $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset(); |
733 | 733 | $instance->LIB = new stdClass(); |
734 | - foreach( array_keys( $instance->non_abstract_db_models ) as $model_name ){ |
|
735 | - $instance->reset_model( $model_name ); |
|
734 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
735 | + $instance->reset_model($model_name); |
|
736 | 736 | } |
737 | 737 | return $instance; |
738 | 738 | } |
@@ -743,9 +743,9 @@ discard block |
||
743 | 743 | */ |
744 | 744 | public function cpt_models() { |
745 | 745 | $cpt_models = array(); |
746 | - foreach( $this->non_abstract_db_models as $shortname => $classname ) { |
|
747 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
748 | - $cpt_models[ $shortname ] = $classname; |
|
746 | + foreach ($this->non_abstract_db_models as $shortname => $classname) { |
|
747 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
748 | + $cpt_models[$shortname] = $classname; |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | return $cpt_models; |
@@ -11,25 +11,25 @@ discard block |
||
11 | 11 | final class EE_Registry { |
12 | 12 | |
13 | 13 | /** |
14 | - * EE_Registry Object |
|
15 | - * @var EE_Registry $_instance |
|
16 | - * @access private |
|
17 | - */ |
|
14 | + * EE_Registry Object |
|
15 | + * @var EE_Registry $_instance |
|
16 | + * @access private |
|
17 | + */ |
|
18 | 18 | private static $_instance = NULL; |
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
22 | - * EE_Cart Object |
|
23 | - * @access public |
|
24 | - * @var EE_Cart $CART |
|
25 | - */ |
|
22 | + * EE_Cart Object |
|
23 | + * @access public |
|
24 | + * @var EE_Cart $CART |
|
25 | + */ |
|
26 | 26 | public $CART = NULL; |
27 | 27 | |
28 | 28 | /** |
29 | - * EE_Config Object |
|
30 | - * @access public |
|
31 | - * @var EE_Config $CFG |
|
32 | - */ |
|
29 | + * EE_Config Object |
|
30 | + * @access public |
|
31 | + * @var EE_Config $CFG |
|
32 | + */ |
|
33 | 33 | public $CFG = NULL; |
34 | 34 | |
35 | 35 | |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | |
46 | 46 | /** |
47 | - * StdClass object for storing library classes in |
|
48 | - * @public LIB |
|
49 | - */ |
|
47 | + * StdClass object for storing library classes in |
|
48 | + * @public LIB |
|
49 | + */ |
|
50 | 50 | public $LIB = NULL; |
51 | 51 | |
52 | 52 | /** |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | public $REQ = NULL; |
58 | 58 | |
59 | 59 | /** |
60 | - * EE_Session Object |
|
61 | - * @access public |
|
62 | - * @var EE_Session $SSN |
|
63 | - */ |
|
60 | + * EE_Session Object |
|
61 | + * @access public |
|
62 | + * @var EE_Session $SSN |
|
63 | + */ |
|
64 | 64 | public $SSN = NULL; |
65 | 65 | |
66 | 66 | |
@@ -127,21 +127,21 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | /** |
130 | - * $i18n_js_strings - internationalization for JS strings |
|
131 | - * usage: EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' ); |
|
132 | - * in js file: var translatedString = eei18n.string_key; |
|
133 | - * |
|
134 | - * @access public |
|
135 | - * @var array |
|
136 | - */ |
|
130 | + * $i18n_js_strings - internationalization for JS strings |
|
131 | + * usage: EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' ); |
|
132 | + * in js file: var translatedString = eei18n.string_key; |
|
133 | + * |
|
134 | + * @access public |
|
135 | + * @var array |
|
136 | + */ |
|
137 | 137 | public static $i18n_js_strings = array(); |
138 | 138 | |
139 | 139 | /** |
140 | - * $main_file - path to espresso.php |
|
141 | - * |
|
142 | - * @access public |
|
143 | - * @var array |
|
144 | - */ |
|
140 | + * $main_file - path to espresso.php |
|
141 | + * |
|
142 | + * @access public |
|
143 | + * @var array |
|
144 | + */ |
|
145 | 145 | public $main_file; |
146 | 146 | |
147 | 147 |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * is_espresso_page |
272 | 272 | * |
273 | 273 | * @access public |
274 | - * @param null $value |
|
274 | + * @param boolean $value |
|
275 | 275 | * @return mixed |
276 | 276 | */ |
277 | 277 | public function set_espresso_page( $value = null ) { |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * setter |
308 | 308 | * |
309 | 309 | * @access public |
310 | - * @param $key |
|
310 | + * @param string $key |
|
311 | 311 | * @param $value |
312 | 312 | * @param bool $override_ee |
313 | 313 | * @return void |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * remove param |
353 | 353 | * |
354 | 354 | * @access public |
355 | - * @param $key |
|
355 | + * @param string $key |
|
356 | 356 | * @return void |
357 | 357 | */ |
358 | 358 | public function un_set( $key ) { |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * add_output |
393 | 393 | * |
394 | 394 | * @access public |
395 | - * @param $string |
|
395 | + * @param string $string |
|
396 | 396 | * @return void |
397 | 397 | */ |
398 | 398 | public function add_output( $string ) { |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | * @param WP $wp |
66 | 66 | * @return \EE_Request_Handler |
67 | 67 | */ |
68 | - public function __construct( $wp = null ) { |
|
68 | + public function __construct($wp = null) { |
|
69 | 69 | //if somebody forgot to provide us with WP, that's ok because its global |
70 | - if ( ! $wp instanceof WP ){ |
|
70 | + if ( ! $wp instanceof WP) { |
|
71 | 71 | global $wp; |
72 | 72 | } |
73 | 73 | // grab request vars |
74 | 74 | $this->_params = $_REQUEST; |
75 | 75 | // AJAX ??? |
76 | - $this->ajax = defined( 'DOING_AJAX' ) ? true : false; |
|
77 | - $this->front_ajax = $this->is_set( 'ee_front_ajax' ) && $this->get( 'ee_front_ajax' ) == 1 ? true : false; |
|
78 | - $this->set_request_vars( $wp ); |
|
79 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
76 | + $this->ajax = defined('DOING_AJAX') ? true : false; |
|
77 | + $this->front_ajax = $this->is_set('ee_front_ajax') && $this->get('ee_front_ajax') == 1 ? true : false; |
|
78 | + $this->set_request_vars($wp); |
|
79 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | * @param WP $wp |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function set_request_vars( $wp = null ) { |
|
92 | - if ( ! is_admin() ) { |
|
91 | + public function set_request_vars($wp = null) { |
|
92 | + if ( ! is_admin()) { |
|
93 | 93 | // set request post_id |
94 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
94 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
95 | 95 | // set request post name |
96 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
96 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
97 | 97 | // set request post_type |
98 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
98 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
99 | 99 | // true or false ? is this page being used by EE ? |
100 | 100 | $this->set_espresso_page(); |
101 | 101 | } |
@@ -110,20 +110,20 @@ discard block |
||
110 | 110 | * @param WP $wp |
111 | 111 | * @return int |
112 | 112 | */ |
113 | - public function get_post_id_from_request( $wp = null ) { |
|
114 | - if ( ! $wp instanceof WP ){ |
|
113 | + public function get_post_id_from_request($wp = null) { |
|
114 | + if ( ! $wp instanceof WP) { |
|
115 | 115 | global $wp; |
116 | 116 | } |
117 | 117 | $post_id = null; |
118 | - if ( isset( $wp->query_vars['p'] )) { |
|
118 | + if (isset($wp->query_vars['p'])) { |
|
119 | 119 | $post_id = $wp->query_vars['p']; |
120 | 120 | } |
121 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
121 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
122 | 122 | $post_id = $wp->query_vars['page_id']; |
123 | 123 | } |
124 | - if ( ! $post_id && isset( $wp->request )) { |
|
125 | - if ( is_numeric( basename( $wp->request ))) { |
|
126 | - $post_id = basename( $wp->request ); |
|
124 | + if ( ! $post_id && isset($wp->request)) { |
|
125 | + if (is_numeric(basename($wp->request))) { |
|
126 | + $post_id = basename($wp->request); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | return $post_id; |
@@ -138,35 +138,35 @@ discard block |
||
138 | 138 | * @param WP $wp |
139 | 139 | * @return string |
140 | 140 | */ |
141 | - public function get_post_name_from_request( $wp = null ) { |
|
142 | - if ( ! $wp instanceof WP ){ |
|
141 | + public function get_post_name_from_request($wp = null) { |
|
142 | + if ( ! $wp instanceof WP) { |
|
143 | 143 | global $wp; |
144 | 144 | } |
145 | 145 | $post_name = null; |
146 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
146 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
147 | 147 | $post_name = $wp->query_vars['name']; |
148 | 148 | } |
149 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
149 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
150 | 150 | $post_name = $wp->query_vars['pagename']; |
151 | 151 | } |
152 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
153 | - $possible_post_name = basename( $wp->request ); |
|
154 | - if ( ! is_numeric( $possible_post_name )) { |
|
152 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
153 | + $possible_post_name = basename($wp->request); |
|
154 | + if ( ! is_numeric($possible_post_name)) { |
|
155 | 155 | /** @type WPDB $wpdb */ |
156 | 156 | global $wpdb; |
157 | 157 | $SQL = "SELECT ID from $wpdb->posts WHERE post_status='publish' AND post_name=%s"; |
158 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
159 | - if ( $possible_post_name ) { |
|
158 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
159 | + if ($possible_post_name) { |
|
160 | 160 | $post_name = $possible_post_name; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
164 | + if ( ! $post_name && $this->get('post_id')) { |
|
165 | 165 | /** @type WPDB $wpdb */ |
166 | 166 | global $wpdb; |
167 | 167 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_status='publish' AND ID=%d"; |
168 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
169 | - if( $possible_post_name ) { |
|
168 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
169 | + if ($possible_post_name) { |
|
170 | 170 | $post_name = $possible_post_name; |
171 | 171 | } |
172 | 172 | } |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | * @param WP $wp |
183 | 183 | * @return mixed |
184 | 184 | */ |
185 | - public function get_post_type_from_request( $wp = null ) { |
|
186 | - if ( ! $wp instanceof WP ){ |
|
185 | + public function get_post_type_from_request($wp = null) { |
|
186 | + if ( ! $wp instanceof WP) { |
|
187 | 187 | global $wp; |
188 | 188 | } |
189 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
189 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | * @param WP $wp |
197 | 197 | * @return bool|string|void |
198 | 198 | */ |
199 | - public function get_current_page_permalink( $wp = null ) { |
|
200 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
201 | - if ( $post_id ) { |
|
202 | - $current_page_permalink = get_permalink( $post_id ); |
|
199 | + public function get_current_page_permalink($wp = null) { |
|
200 | + $post_id = $this->get_post_id_from_request($wp); |
|
201 | + if ($post_id) { |
|
202 | + $current_page_permalink = get_permalink($post_id); |
|
203 | 203 | } else { |
204 | - if ( ! $wp instanceof WP ) { |
|
204 | + if ( ! $wp instanceof WP) { |
|
205 | 205 | global $wp; |
206 | 206 | } |
207 | - if ( $wp->request ) { |
|
208 | - $current_page_permalink = site_url( $wp->request ); |
|
207 | + if ($wp->request) { |
|
208 | + $current_page_permalink = site_url($wp->request); |
|
209 | 209 | } else { |
210 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
210 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | return $current_page_permalink; |
@@ -224,41 +224,41 @@ discard block |
||
224 | 224 | public function test_for_espresso_page() { |
225 | 225 | global $wp; |
226 | 226 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
227 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
227 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
228 | 228 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
229 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
230 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
231 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
229 | + if (is_array($espresso_CPT_taxonomies)) { |
|
230 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
231 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
232 | 232 | return true; |
233 | 233 | } |
234 | 234 | } |
235 | 235 | } |
236 | 236 | // load espresso CPT endpoints |
237 | 237 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
238 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
239 | - $post_types = (array)$this->get( 'post_type' ); |
|
240 | - foreach ( $post_types as $post_type ) { |
|
238 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
239 | + $post_types = (array) $this->get('post_type'); |
|
240 | + foreach ($post_types as $post_type) { |
|
241 | 241 | // was a post name passed ? |
242 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
242 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
243 | 243 | // kk we know this is an espresso page, but is it a specific post ? |
244 | - if ( ! $this->get( 'post_name' ) ) { |
|
244 | + if ( ! $this->get('post_name')) { |
|
245 | 245 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
246 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] : null; |
|
246 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) ? $post_type_CPT_endpoints[$this->get('post_type')] : null; |
|
247 | 247 | // if the post type matches on of our then set the endpoint |
248 | - if ( $post_name ) { |
|
249 | - $this->set( 'post_name', $post_name ); |
|
248 | + if ($post_name) { |
|
249 | + $this->set('post_name', $post_name); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | return true; |
253 | 253 | } |
254 | 254 | } |
255 | - if ( $this->get( 'post_name' )) { |
|
255 | + if ($this->get('post_name')) { |
|
256 | 256 | // load all pages using espresso shortcodes |
257 | - $post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
257 | + $post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
258 | 258 | // make sure core pages are included |
259 | - $espresso_pages = array_merge( $espresso_CPT_endpoints, $post_shortcodes ); |
|
259 | + $espresso_pages = array_merge($espresso_CPT_endpoints, $post_shortcodes); |
|
260 | 260 | // was a post name passed ? |
261 | - if ( isset( $espresso_pages[ $this->get( 'post_name' ) ] )) { |
|
261 | + if (isset($espresso_pages[$this->get('post_name')])) { |
|
262 | 262 | return true; |
263 | 263 | } |
264 | 264 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @param null $value |
275 | 275 | * @return mixed |
276 | 276 | */ |
277 | - public function set_espresso_page( $value = null ) { |
|
277 | + public function set_espresso_page($value = null) { |
|
278 | 278 | $value = $value ? $value : $this->test_for_espresso_page(); |
279 | 279 | $this->_params['is_espresso_page'] = $value; |
280 | 280 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @return mixed |
289 | 289 | */ |
290 | 290 | public function is_espresso_page() { |
291 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
291 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | * @param bool $override_ee |
313 | 313 | * @return void |
314 | 314 | */ |
315 | - public function set( $key, $value, $override_ee = false ) { |
|
315 | + public function set($key, $value, $override_ee = false) { |
|
316 | 316 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
317 | - if ( $key != 'ee' || ( $key == 'ee' && empty( $this->_params['ee'] )) || ( $key == 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )) { |
|
318 | - $this->_params[ $key ] = $value; |
|
317 | + if ($key != 'ee' || ($key == 'ee' && empty($this->_params['ee'])) || ($key == 'ee' && ! empty($this->_params['ee']) && $override_ee)) { |
|
318 | + $this->_params[$key] = $value; |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | * @param null $default |
330 | 330 | * @return mixed |
331 | 331 | */ |
332 | - public function get( $key, $default = null ) { |
|
333 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
332 | + public function get($key, $default = null) { |
|
333 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @param $key |
343 | 343 | * @return boolean |
344 | 344 | */ |
345 | - public function is_set( $key ) { |
|
346 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
345 | + public function is_set($key) { |
|
346 | + return isset($this->_params[$key]) ? true : false; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param $key |
356 | 356 | * @return void |
357 | 357 | */ |
358 | - public function un_set( $key ) { |
|
359 | - unset( $this->_params[ $key ] ); |
|
358 | + public function un_set($key) { |
|
359 | + unset($this->_params[$key]); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | * @param $value |
370 | 370 | * @return void |
371 | 371 | */ |
372 | - public function set_notice( $key, $value ) { |
|
373 | - $this->_notice[ $key ] = $value; |
|
372 | + public function set_notice($key, $value) { |
|
373 | + $this->_notice[$key] = $value; |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @param $key |
383 | 383 | * @return mixed |
384 | 384 | */ |
385 | - public function get_notice( $key ) { |
|
386 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
385 | + public function get_notice($key) { |
|
386 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | * @param $string |
396 | 396 | * @return void |
397 | 397 | */ |
398 | - public function add_output( $string ) { |
|
398 | + public function add_output($string) { |
|
399 | 399 | $this->_output .= $string; |
400 | 400 | } |
401 | 401 | |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * @param $item |
418 | 418 | * @param $key |
419 | 419 | */ |
420 | - function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
421 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
420 | + function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
421 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @param $b |
429 | 429 | * @return bool |
430 | 430 | */ |
431 | - public function __set($a,$b) { return false; } |
|
431 | + public function __set($a, $b) { return false; } |
|
432 | 432 | |
433 | 433 | |
434 | 434 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | /** |
337 | 337 | * retrieve session data |
338 | 338 | * @access public |
339 | - * @param null $key |
|
339 | + * @param string|null $key |
|
340 | 340 | * @param bool $reset_cache |
341 | 341 | * @return array |
342 | 342 | */ |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * set session data |
361 | 361 | * @access public |
362 | 362 | * @param array $data |
363 | - * @return TRUE on success, FALSE on fail |
|
363 | + * @return boolean on success, FALSE on fail |
|
364 | 364 | */ |
365 | 365 | public function set_session_data( $data ) { |
366 | 366 | |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | /** |
391 | 391 | * @initiate session |
392 | 392 | * @access private |
393 | - * @return TRUE on success, FALSE on fail |
|
393 | + * @return boolean on success, FALSE on fail |
|
394 | 394 | * @throws \EE_Error |
395 | 395 | */ |
396 | 396 | private function _espresso_session() { |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @update session data prior to saving to the db |
522 | 522 | * @access public |
523 | 523 | * @param bool $new_session |
524 | - * @return TRUE on success, FALSE on fail |
|
524 | + * @return boolean on success, FALSE on fail |
|
525 | 525 | */ |
526 | 526 | public function update( $new_session = FALSE ) { |
527 | 527 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | * @access public |
792 | 792 | * @param array $data_to_reset |
793 | 793 | * @param bool $show_all_notices |
794 | - * @return TRUE on success, FALSE on fail |
|
794 | + * @return boolean on success, FALSE on fail |
|
795 | 795 | */ |
796 | 796 | public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
797 | 797 | // if $data_to_reset is not in an array, then put it in one |
@@ -137,11 +137,11 @@ |
||
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
140 | - * private constructor to prevent direct creation |
|
141 | - * @Constructor |
|
142 | - * @access private |
|
143 | - * @return EE_Session |
|
144 | - */ |
|
140 | + * private constructor to prevent direct creation |
|
141 | + * @Constructor |
|
142 | + * @access private |
|
143 | + * @return EE_Session |
|
144 | + */ |
|
145 | 145 | private function __construct() { |
146 | 146 | |
147 | 147 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );/** |
3 | 5 | * |
4 | 6 | * Event Espresso |
@@ -349,7 +351,7 @@ discard block |
||
349 | 351 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
350 | 352 | if ( ! empty( $key )) { |
351 | 353 | return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
352 | - } else { |
|
354 | + } else { |
|
353 | 355 | return $this->_session_data; |
354 | 356 | } |
355 | 357 | } |
@@ -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 | * Event Espresso |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * array for defining default session vars |
105 | 105 | * @var array |
106 | 106 | */ |
107 | - private $_default_session_vars = array ( |
|
107 | + private $_default_session_vars = array( |
|
108 | 108 | 'id' => NULL, |
109 | 109 | 'user_id' => NULL, |
110 | 110 | 'ip_address' => NULL, |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @return EE_Session |
128 | 128 | */ |
129 | - public static function instance ( ) { |
|
129 | + public static function instance( ) { |
|
130 | 130 | // check if class object is instantiated |
131 | - if ( ! self::$_instance instanceof EE_Session ) { |
|
131 | + if ( ! self::$_instance instanceof EE_Session) { |
|
132 | 132 | self::$_instance = new self(); |
133 | 133 | } |
134 | 134 | return self::$_instance; |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | private function __construct() { |
146 | 146 | |
147 | 147 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
148 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
148 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
149 | 149 | return NULL; |
150 | 150 | } |
151 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
152 | - define( 'ESPRESSO_SESSION', TRUE ); |
|
151 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
152 | + define('ESPRESSO_SESSION', TRUE); |
|
153 | 153 | // default session lifespan in seconds |
154 | 154 | $this->_lifespan = apply_filters( |
155 | 155 | 'FHEE__EE_Session__construct___lifespan', |
@@ -162,35 +162,35 @@ discard block |
||
162 | 162 | * } |
163 | 163 | */ |
164 | 164 | // retrieve session options from db |
165 | - $session_settings = get_option( 'ee_session_settings' ); |
|
166 | - if ( $session_settings !== FALSE ) { |
|
165 | + $session_settings = get_option('ee_session_settings'); |
|
166 | + if ($session_settings !== FALSE) { |
|
167 | 167 | // cycle though existing session options |
168 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
168 | + foreach ($session_settings as $var_name => $session_setting) { |
|
169 | 169 | // set values for class properties |
170 | - $var_name = '_' . $var_name; |
|
170 | + $var_name = '_'.$var_name; |
|
171 | 171 | $this->{$var_name} = $session_setting; |
172 | 172 | } |
173 | 173 | } |
174 | 174 | // are we using encryption? |
175 | - if ( $this->_use_encryption ) { |
|
175 | + if ($this->_use_encryption) { |
|
176 | 176 | // instantiate the class object making all properties and methods accessible via $this->encryption ex: $this->encryption->encrypt(); |
177 | - $this->encryption = EE_Registry::instance()->load_core( 'Encryption' ); |
|
177 | + $this->encryption = EE_Registry::instance()->load_core('Encryption'); |
|
178 | 178 | } |
179 | 179 | // filter hook allows outside functions/classes/plugins to change default empty cart |
180 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
181 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
180 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
181 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
182 | 182 | // apply default session vars |
183 | 183 | $this->_set_defaults(); |
184 | 184 | // check for existing session and retrieve it from db |
185 | - if ( ! $this->_espresso_session() ) { |
|
185 | + if ( ! $this->_espresso_session()) { |
|
186 | 186 | // or just start a new one |
187 | 187 | $this->_create_espresso_session(); |
188 | 188 | } |
189 | 189 | // check request for 'clear_session' param |
190 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
190 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
191 | 191 | // once everything is all said and done, |
192 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
193 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
192 | + add_action('shutdown', array($this, 'update'), 100); |
|
193 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
194 | 194 | |
195 | 195 | } |
196 | 196 | |
@@ -222,11 +222,11 @@ discard block |
||
222 | 222 | */ |
223 | 223 | private function _set_defaults() { |
224 | 224 | // set some defaults |
225 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
226 | - if ( is_array( $default_var )) { |
|
227 | - $this->_session_data[ $key ] = array(); |
|
225 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
226 | + if (is_array($default_var)) { |
|
227 | + $this->_session_data[$key] = array(); |
|
228 | 228 | } else { |
229 | - $this->_session_data[ $key ] = ''; |
|
229 | + $this->_session_data[$key] = ''; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @param \EE_Cart $cart |
249 | 249 | * @return bool |
250 | 250 | */ |
251 | - public function set_cart( EE_Cart $cart ) { |
|
251 | + public function set_cart(EE_Cart $cart) { |
|
252 | 252 | $this->_session_data['cart'] = $cart; |
253 | 253 | return TRUE; |
254 | 254 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return \EE_Cart |
269 | 269 | */ |
270 | 270 | public function cart() { |
271 | - return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL; |
|
271 | + return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param \EE_Checkout $checkout |
278 | 278 | * @return bool |
279 | 279 | */ |
280 | - public function set_checkout( EE_Checkout $checkout ) { |
|
280 | + public function set_checkout(EE_Checkout $checkout) { |
|
281 | 281 | $this->_session_data['checkout'] = $checkout; |
282 | 282 | return TRUE; |
283 | 283 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return \EE_Checkout |
298 | 298 | */ |
299 | 299 | public function checkout() { |
300 | - return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL; |
|
300 | + return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | * @param \EE_Transaction $transaction |
307 | 307 | * @return bool |
308 | 308 | */ |
309 | - public function set_transaction( EE_Transaction $transaction ) { |
|
309 | + public function set_transaction(EE_Transaction $transaction) { |
|
310 | 310 | // first remove the session from the transaction before we save the transaction in the session |
311 | - $transaction->set_txn_session_data( NULL ); |
|
311 | + $transaction->set_txn_session_data(NULL); |
|
312 | 312 | $this->_session_data['transaction'] = $transaction; |
313 | 313 | return TRUE; |
314 | 314 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return \EE_Transaction |
329 | 329 | */ |
330 | 330 | public function transaction() { |
331 | - return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL; |
|
331 | + return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | * @param bool $reset_cache |
341 | 341 | * @return array |
342 | 342 | */ |
343 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
344 | - if ( $reset_cache ) { |
|
343 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
344 | + if ($reset_cache) { |
|
345 | 345 | $this->reset_cart(); |
346 | 346 | $this->reset_checkout(); |
347 | 347 | $this->reset_transaction(); |
348 | 348 | } |
349 | - if ( ! empty( $key )) { |
|
350 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
351 | - } else { |
|
349 | + if ( ! empty($key)) { |
|
350 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
351 | + } else { |
|
352 | 352 | return $this->_session_data; |
353 | 353 | } |
354 | 354 | } |
@@ -361,20 +361,20 @@ discard block |
||
361 | 361 | * @param array $data |
362 | 362 | * @return TRUE on success, FALSE on fail |
363 | 363 | */ |
364 | - public function set_session_data( $data ) { |
|
364 | + public function set_session_data($data) { |
|
365 | 365 | |
366 | 366 | // nothing ??? bad data ??? go home! |
367 | - if ( empty( $data ) || ! is_array( $data )) { |
|
368 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
367 | + if (empty($data) || ! is_array($data)) { |
|
368 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
369 | 369 | return FALSE; |
370 | 370 | } |
371 | 371 | |
372 | - foreach ( $data as $key =>$value ) { |
|
373 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
374 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
372 | + foreach ($data as $key =>$value) { |
|
373 | + if (isset($this->_default_session_vars[$key])) { |
|
374 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
375 | 375 | return FALSE; |
376 | 376 | } else { |
377 | - $this->_session_data[ $key ] = $value; |
|
377 | + $this->_session_data[$key] = $value; |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | * @throws \EE_Error |
392 | 392 | */ |
393 | 393 | private function _espresso_session() { |
394 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
394 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
395 | 395 | // check that session has started |
396 | - if ( session_id() === '' ) { |
|
396 | + if (session_id() === '') { |
|
397 | 397 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
398 | 398 | session_start(); |
399 | 399 | } |
@@ -402,57 +402,57 @@ discard block |
||
402 | 402 | // and the visitors IP |
403 | 403 | $this->_ip_address = $this->_visitor_ip(); |
404 | 404 | // set the "user agent" |
405 | - $this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
405 | + $this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
406 | 406 | // now let's retrieve what's in the db |
407 | 407 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
408 | - $session_data = get_transient( EE_Session::session_id_prefix . $this->_sid ); |
|
409 | - if ( $session_data ) { |
|
410 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
411 | - $hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid ); |
|
412 | - if ( $hash_check && $hash_check !== md5( $session_data ) ) { |
|
408 | + $session_data = get_transient(EE_Session::session_id_prefix.$this->_sid); |
|
409 | + if ($session_data) { |
|
410 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
411 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
412 | + if ($hash_check && $hash_check !== md5($session_data)) { |
|
413 | 413 | EE_Error::add_error( |
414 | 414 | sprintf( |
415 | - __( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ), |
|
416 | - EE_Session::session_id_prefix . $this->_sid |
|
415 | + __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
|
416 | + EE_Session::session_id_prefix.$this->_sid |
|
417 | 417 | ), |
418 | 418 | __FILE__, __FUNCTION__, __LINE__ |
419 | 419 | ); |
420 | 420 | } |
421 | 421 | } |
422 | 422 | // un-encrypt the data |
423 | - $session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data; |
|
423 | + $session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data; |
|
424 | 424 | // unserialize |
425 | - $session_data = maybe_unserialize( $session_data ); |
|
425 | + $session_data = maybe_unserialize($session_data); |
|
426 | 426 | // just a check to make sure the session array is indeed an array |
427 | - if ( ! is_array( $session_data ) ) { |
|
427 | + if ( ! is_array($session_data)) { |
|
428 | 428 | // no?!?! then something is wrong |
429 | 429 | return FALSE; |
430 | 430 | } |
431 | 431 | // get the current time in UTC |
432 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
432 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
433 | 433 | // and reset the session expiration |
434 | - $this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
434 | + $this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan; |
|
435 | 435 | |
436 | 436 | } else { |
437 | 437 | // set initial site access time and the session expiration |
438 | 438 | $this->_set_init_access_and_expiration(); |
439 | 439 | // set referer |
440 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : ''; |
|
440 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : ''; |
|
441 | 441 | // no previous session = go back and create one (on top of the data above) |
442 | 442 | return FALSE; |
443 | 443 | } |
444 | 444 | // now the user agent |
445 | - if ( $session_data['user_agent'] != $this->_user_agent ) { |
|
445 | + if ($session_data['user_agent'] != $this->_user_agent) { |
|
446 | 446 | return FALSE; |
447 | 447 | } |
448 | 448 | // wait a minute... how old are you? |
449 | - if ( $this->_time > $this->_expiration ) { |
|
449 | + if ($this->_time > $this->_expiration) { |
|
450 | 450 | // yer too old fer me! |
451 | 451 | // wipe out everything that isn't a default session datum |
452 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
452 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
453 | 453 | } |
454 | 454 | // make event espresso session data available to plugin |
455 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
455 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
456 | 456 | return TRUE; |
457 | 457 | |
458 | 458 | } |
@@ -470,12 +470,12 @@ discard block |
||
470 | 470 | */ |
471 | 471 | protected function _generate_session_id() { |
472 | 472 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
473 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
474 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
473 | + if (isset($_REQUEST['EESID'])) { |
|
474 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
475 | 475 | } else { |
476 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
476 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
477 | 477 | } |
478 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
478 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
@@ -487,20 +487,20 @@ discard block |
||
487 | 487 | */ |
488 | 488 | protected function _get_sid_salt() { |
489 | 489 | // was session id salt already saved to db ? |
490 | - if ( empty( $this->_sid_salt ) ) { |
|
490 | + if (empty($this->_sid_salt)) { |
|
491 | 491 | // no? then maybe use WP defined constant |
492 | - if ( defined( 'AUTH_SALT' ) ) { |
|
492 | + if (defined('AUTH_SALT')) { |
|
493 | 493 | $this->_sid_salt = AUTH_SALT; |
494 | 494 | } |
495 | 495 | // if salt doesn't exist or is too short |
496 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
496 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
497 | 497 | // create a new one |
498 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
498 | + $this->_sid_salt = wp_generate_password(64); |
|
499 | 499 | } |
500 | 500 | // and save it as a permanent session setting |
501 | - $session_settings = get_option( 'ee_session_settings' ); |
|
502 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
503 | - update_option( 'ee_session_settings', $session_settings ); |
|
501 | + $session_settings = get_option('ee_session_settings'); |
|
502 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
503 | + update_option('ee_session_settings', $session_settings); |
|
504 | 504 | } |
505 | 505 | return $this->_sid_salt; |
506 | 506 | } |
@@ -528,19 +528,19 @@ discard block |
||
528 | 528 | * @param bool $new_session |
529 | 529 | * @return TRUE on success, FALSE on fail |
530 | 530 | */ |
531 | - public function update( $new_session = FALSE ) { |
|
532 | - $this->_session_data = isset( $this->_session_data ) |
|
533 | - && is_array( $this->_session_data ) |
|
534 | - && isset( $this->_session_data['id']) |
|
531 | + public function update($new_session = FALSE) { |
|
532 | + $this->_session_data = isset($this->_session_data) |
|
533 | + && is_array($this->_session_data) |
|
534 | + && isset($this->_session_data['id']) |
|
535 | 535 | ? $this->_session_data |
536 | 536 | : NULL; |
537 | - if ( empty( $this->_session_data )) { |
|
537 | + if (empty($this->_session_data)) { |
|
538 | 538 | $this->_set_defaults(); |
539 | 539 | } |
540 | 540 | $session_data = array(); |
541 | - foreach ( $this->_session_data as $key => $value ) { |
|
541 | + foreach ($this->_session_data as $key => $value) { |
|
542 | 542 | |
543 | - switch( $key ) { |
|
543 | + switch ($key) { |
|
544 | 544 | |
545 | 545 | case 'id' : |
546 | 546 | // session ID |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | break; |
559 | 559 | |
560 | 560 | case 'init_access' : |
561 | - $session_data['init_access'] = absint( $value ); |
|
561 | + $session_data['init_access'] = absint($value); |
|
562 | 562 | break; |
563 | 563 | |
564 | 564 | case 'last_access' : |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | |
569 | 569 | case 'expiration' : |
570 | 570 | // when the session expires |
571 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
571 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
572 | 572 | ? $this->_expiration |
573 | 573 | : $session_data['init_access'] + $this->_lifespan; |
574 | 574 | break; |
@@ -580,11 +580,11 @@ discard block |
||
580 | 580 | |
581 | 581 | case 'pages_visited' : |
582 | 582 | $page_visit = $this->_get_page_visit(); |
583 | - if ( $page_visit ) { |
|
583 | + if ($page_visit) { |
|
584 | 584 | // set pages visited where the first will be the http referrer |
585 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
585 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
586 | 586 | // we'll only save the last 10 page visits. |
587 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
587 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
588 | 588 | } |
589 | 589 | break; |
590 | 590 | |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | |
599 | 599 | $this->_session_data = $session_data; |
600 | 600 | // creating a new session does not require saving to the db just yet |
601 | - if ( ! $new_session ) { |
|
601 | + if ( ! $new_session) { |
|
602 | 602 | // ready? let's save |
603 | - if ( $this->_save_session_to_db() ) { |
|
603 | + if ($this->_save_session_to_db()) { |
|
604 | 604 | return TRUE; |
605 | 605 | } else { |
606 | 606 | return FALSE; |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | * @return bool |
622 | 622 | */ |
623 | 623 | private function _create_espresso_session( ) { |
624 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
624 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
625 | 625 | // use the update function for now with $new_session arg set to TRUE |
626 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
626 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
@@ -647,15 +647,15 @@ discard block |
||
647 | 647 | return FALSE; |
648 | 648 | } |
649 | 649 | // first serialize all of our session data |
650 | - $session_data = serialize( $this->_session_data ); |
|
650 | + $session_data = serialize($this->_session_data); |
|
651 | 651 | // encrypt it if we are using encryption |
652 | - $session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data; |
|
652 | + $session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data; |
|
653 | 653 | // maybe save hash check |
654 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
655 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan ); |
|
654 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
655 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan); |
|
656 | 656 | } |
657 | 657 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
658 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan ); |
|
658 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | |
@@ -681,10 +681,10 @@ discard block |
||
681 | 681 | 'HTTP_FORWARDED', |
682 | 682 | 'REMOTE_ADDR' |
683 | 683 | ); |
684 | - foreach ( $server_keys as $key ){ |
|
685 | - if ( isset( $_SERVER[ $key ] )) { |
|
686 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
687 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
684 | + foreach ($server_keys as $key) { |
|
685 | + if (isset($_SERVER[$key])) { |
|
686 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
687 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
688 | 688 | $visitor_ip = $ip; |
689 | 689 | } |
690 | 690 | } |
@@ -705,45 +705,45 @@ discard block |
||
705 | 705 | public function _get_page_visit() { |
706 | 706 | |
707 | 707 | // echo '<h3>'. __CLASS__ .'->'.__FUNCTION__.' ( line no: ' . __LINE__ . ' )</h3>'; |
708 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
708 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
709 | 709 | |
710 | 710 | // check for request url |
711 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
711 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
712 | 712 | |
713 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
713 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
714 | 714 | |
715 | - $ru_bits = explode( '?', $request_uri ); |
|
715 | + $ru_bits = explode('?', $request_uri); |
|
716 | 716 | $request_uri = $ru_bits[0]; |
717 | 717 | //echo '<h1>$request_uri ' . $request_uri . '</h1>'; |
718 | 718 | |
719 | 719 | // check for and grab host as well |
720 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
721 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
720 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
721 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
722 | 722 | } else { |
723 | 723 | $http_host = ''; |
724 | 724 | } |
725 | 725 | //echo '<h1>$http_host ' . $http_host . '</h1>'; |
726 | 726 | |
727 | 727 | // check for page_id in SERVER REQUEST |
728 | - if ( isset( $_REQUEST['page_id'] )) { |
|
728 | + if (isset($_REQUEST['page_id'])) { |
|
729 | 729 | // rebuild $e_reg without any of the extra parameters |
730 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
730 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
731 | 731 | } else { |
732 | 732 | $page_id = '?'; |
733 | 733 | } |
734 | 734 | // check for $e_reg in SERVER REQUEST |
735 | - if ( isset( $_REQUEST['ee'] )) { |
|
735 | + if (isset($_REQUEST['ee'])) { |
|
736 | 736 | // rebuild $e_reg without any of the extra parameters |
737 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
737 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
738 | 738 | } else { |
739 | 739 | $e_reg = ''; |
740 | 740 | } |
741 | 741 | |
742 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
742 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
746 | - return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
746 | + return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
747 | 747 | |
748 | 748 | } |
749 | 749 | |
@@ -772,14 +772,14 @@ discard block |
||
772 | 772 | * @param string $function |
773 | 773 | * @return void |
774 | 774 | */ |
775 | - public function clear_session( $class = '', $function = '' ) { |
|
775 | + public function clear_session($class = '', $function = '') { |
|
776 | 776 | //echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span> <b style="font-size:10px;"> ' . __LINE__ . ' </b></h3>'; |
777 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
777 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
778 | 778 | $this->reset_cart(); |
779 | 779 | $this->reset_checkout(); |
780 | 780 | $this->reset_transaction(); |
781 | 781 | // wipe out everything that isn't a default session datum |
782 | - $this->reset_data( array_keys( $this->_session_data )); |
|
782 | + $this->reset_data(array_keys($this->_session_data)); |
|
783 | 783 | // reset initial site access time and the session expiration |
784 | 784 | $this->_set_init_access_and_expiration(); |
785 | 785 | $this->_save_session_to_db(); |
@@ -794,42 +794,42 @@ discard block |
||
794 | 794 | * @param bool $show_all_notices |
795 | 795 | * @return TRUE on success, FALSE on fail |
796 | 796 | */ |
797 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
797 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
798 | 798 | // if $data_to_reset is not in an array, then put it in one |
799 | - if ( ! is_array( $data_to_reset ) ) { |
|
800 | - $data_to_reset = array ( $data_to_reset ); |
|
799 | + if ( ! is_array($data_to_reset)) { |
|
800 | + $data_to_reset = array($data_to_reset); |
|
801 | 801 | } |
802 | 802 | // nothing ??? go home! |
803 | - if ( empty( $data_to_reset )) { |
|
804 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
803 | + if (empty($data_to_reset)) { |
|
804 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
805 | 805 | return FALSE; |
806 | 806 | } |
807 | 807 | $return_value = TRUE; |
808 | 808 | // since $data_to_reset is an array, cycle through the values |
809 | - foreach ( $data_to_reset as $reset ) { |
|
809 | + foreach ($data_to_reset as $reset) { |
|
810 | 810 | |
811 | 811 | // first check to make sure it is a valid session var |
812 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
812 | + if (isset($this->_session_data[$reset])) { |
|
813 | 813 | // then check to make sure it is not a default var |
814 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
814 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
815 | 815 | // remove session var |
816 | - unset( $this->_session_data[ $reset ] ); |
|
817 | - if ( $show_all_notices ) { |
|
818 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
816 | + unset($this->_session_data[$reset]); |
|
817 | + if ($show_all_notices) { |
|
818 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
819 | 819 | } |
820 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
820 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
821 | 821 | |
822 | 822 | } else { |
823 | 823 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
824 | - if ( $show_all_notices ) { |
|
825 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
824 | + if ($show_all_notices) { |
|
825 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
826 | 826 | } |
827 | 827 | $return_value = FALSE; |
828 | 828 | } |
829 | 829 | |
830 | - } else if ( $show_all_notices ) { |
|
830 | + } else if ($show_all_notices) { |
|
831 | 831 | // oops! that session var does not exist! |
832 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
832 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
833 | 833 | $return_value = FALSE; |
834 | 834 | } |
835 | 835 | |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | * @return string |
851 | 851 | */ |
852 | 852 | public function wp_loaded() { |
853 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
854 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
853 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
854 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | |
@@ -876,24 +876,24 @@ discard block |
||
876 | 876 | */ |
877 | 877 | public function garbage_collection() { |
878 | 878 | // only perform during regular requests |
879 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
879 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
880 | 880 | /** @type WPDB $wpdb */ |
881 | 881 | global $wpdb; |
882 | 882 | // since transient expiration timestamps are set in the future, we can compare against NOW |
883 | 883 | $expiration = time(); |
884 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ); |
|
884 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2); |
|
885 | 885 | // filter the query limit. Set to 0 to turn off garbage collection |
886 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
886 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
887 | 887 | // non-zero LIMIT means take out the trash |
888 | - if ( $expired_session_transient_delete_query_limit ) { |
|
888 | + if ($expired_session_transient_delete_query_limit) { |
|
889 | 889 | //array of transient keys that require garbage collection |
890 | 890 | $session_keys = array( |
891 | 891 | EE_Session::session_id_prefix, |
892 | 892 | EE_Session::hash_check_prefix, |
893 | 893 | ); |
894 | - foreach ( $session_keys as $session_key ) { |
|
895 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
896 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
894 | + foreach ($session_keys as $session_key) { |
|
895 | + $session_key = str_replace('_', '\_', $session_key); |
|
896 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
897 | 897 | $SQL = " |
898 | 898 | SELECT option_name |
899 | 899 | FROM {$wpdb->options} |
@@ -903,28 +903,28 @@ discard block |
||
903 | 903 | OR option_value > {$too_far_in_the_the_future} ) |
904 | 904 | LIMIT {$expired_session_transient_delete_query_limit} |
905 | 905 | "; |
906 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
906 | + $expired_sessions = $wpdb->get_col($SQL); |
|
907 | 907 | // valid results? |
908 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
908 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
909 | 909 | // format array of results into something usable within the actual DELETE query's IN clause |
910 | 910 | $expired = array(); |
911 | - foreach ( $expired_sessions as $expired_session ) { |
|
912 | - $expired[ ] = "'" . $expired_session . "'"; |
|
913 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
911 | + foreach ($expired_sessions as $expired_session) { |
|
912 | + $expired[] = "'".$expired_session."'"; |
|
913 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
914 | 914 | } |
915 | - $expired = implode( ', ', $expired ); |
|
915 | + $expired = implode(', ', $expired); |
|
916 | 916 | $SQL = " |
917 | 917 | DELETE FROM {$wpdb->options} |
918 | 918 | WHERE option_name |
919 | 919 | IN ( $expired ); |
920 | 920 | "; |
921 | - $results = $wpdb->query( $SQL ); |
|
921 | + $results = $wpdb->query($SQL); |
|
922 | 922 | // if something went wrong, then notify the admin |
923 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
924 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
923 | + if ($results instanceof WP_Error && is_admin()) { |
|
924 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
925 | 925 | } |
926 | 926 | } |
927 | - do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit ); |
|
927 | + do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | } |
@@ -613,7 +613,7 @@ |
||
613 | 613 | * so that it will be done when migrations are finished |
614 | 614 | * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
615 | 615 | * however, |
616 | - * @param boolean $verify_db_schema if true will re-check the database tables have the correct schema. This is a resource-intensive job |
|
616 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. This is a resource-intensive job |
|
617 | 617 | * so we prefer to only do it when necessary |
618 | 618 | * @return void |
619 | 619 | */ |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -578,7 +580,7 @@ discard block |
||
578 | 580 | $espresso_db_update = array( $espresso_db_update=>array() ); |
579 | 581 | update_option( 'espresso_db_update', $espresso_db_update ); |
580 | 582 | } |
581 | - }else{ |
|
583 | + } else{ |
|
582 | 584 | $corrected_db_update = array(); |
583 | 585 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
584 | 586 | foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
@@ -588,7 +590,7 @@ discard block |
||
588 | 590 | //fix it! |
589 | 591 | $version_string = $should_be_array; |
590 | 592 | $corrected_db_update[$version_string] = array('unknown-date'); |
591 | - }else{ |
|
593 | + } else{ |
|
592 | 594 | //ok it checks out |
593 | 595 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
594 | 596 | } |
@@ -633,7 +635,7 @@ discard block |
||
633 | 635 | $addon->initialize_db_if_no_migrations_required(); |
634 | 636 | } |
635 | 637 | } |
636 | - }else{ |
|
638 | + } else{ |
|
637 | 639 | EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
638 | 640 | } |
639 | 641 | if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
@@ -703,7 +705,7 @@ discard block |
||
703 | 705 | //it a version we haven't seen before |
704 | 706 | if( $version_is_higher === 1 ){ |
705 | 707 | $req_type = EE_System::req_type_upgrade; |
706 | - }else{ |
|
708 | + } else{ |
|
707 | 709 | $req_type = EE_System::req_type_downgrade; |
708 | 710 | } |
709 | 711 | delete_option( $activation_indicator_option_name ); |
@@ -712,10 +714,10 @@ discard block |
||
712 | 714 | if( get_option( $activation_indicator_option_name, FALSE ) ){ |
713 | 715 | if ( $version_is_higher === -1 ){ |
714 | 716 | $req_type = EE_System::req_type_downgrade; |
715 | - }elseif( $version_is_higher === 0 ){ |
|
717 | + } elseif( $version_is_higher === 0 ){ |
|
716 | 718 | //we've seen this version before, but it's an activation. must be a reactivation |
717 | 719 | $req_type = EE_System::req_type_reactivation; |
718 | - }else{//$version_is_higher === 1 |
|
720 | + } else{//$version_is_higher === 1 |
|
719 | 721 | $req_type = EE_System::req_type_upgrade; |
720 | 722 | } |
721 | 723 | delete_option( $activation_indicator_option_name ); |
@@ -723,10 +725,10 @@ discard block |
||
723 | 725 | //we've seen this version before and the activation indicate doesn't show it was just activated |
724 | 726 | if ( $version_is_higher === -1 ){ |
725 | 727 | $req_type = EE_System::req_type_downgrade; |
726 | - }elseif( $version_is_higher === 0 ){ |
|
728 | + } elseif( $version_is_higher === 0 ){ |
|
727 | 729 | //we've seen this version before and it's not an activation. its normal request |
728 | 730 | $req_type = EE_System::req_type_normal; |
729 | - }else{//$version_is_higher === 1 |
|
731 | + } else{//$version_is_higher === 1 |
|
730 | 732 | $req_type = EE_System::req_type_upgrade; |
731 | 733 | } |
732 | 734 | } |
@@ -203,14 +203,14 @@ discard block |
||
203 | 203 | |
204 | 204 | |
205 | 205 | /** |
206 | - * detect_if_activation_or_upgrade |
|
207 | - * |
|
208 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
209 | - * and either setting up the DB or setting up maintenance mode etc. |
|
210 | - * |
|
211 | - * @access public |
|
212 | - * @return void |
|
213 | - */ |
|
206 | + * detect_if_activation_or_upgrade |
|
207 | + * |
|
208 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
209 | + * and either setting up the DB or setting up maintenance mode etc. |
|
210 | + * |
|
211 | + * @access public |
|
212 | + * @return void |
|
213 | + */ |
|
214 | 214 | public function detect_if_activation_or_upgrade() { |
215 | 215 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
216 | 216 | |
@@ -514,11 +514,11 @@ discard block |
||
514 | 514 | $query_params = array( 'page' => 'espresso_about' ); |
515 | 515 | |
516 | 516 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
517 | - $query_params['new_activation'] = TRUE; |
|
517 | + $query_params['new_activation'] = TRUE; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
521 | - $query_params['reactivation'] = TRUE; |
|
521 | + $query_params['reactivation'] = TRUE; |
|
522 | 522 | } |
523 | 523 | $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
524 | 524 | wp_safe_redirect( $url ); |
@@ -621,11 +621,11 @@ discard block |
||
621 | 621 | |
622 | 622 | |
623 | 623 | /** |
624 | - * _incompatible_addon_error |
|
625 | - * |
|
626 | - * @access public |
|
627 | - * @return void |
|
628 | - */ |
|
624 | + * _incompatible_addon_error |
|
625 | + * |
|
626 | + * @access public |
|
627 | + * @return void |
|
628 | + */ |
|
629 | 629 | private function _incompatible_addon_error() { |
630 | 630 | // get array of classes hooking into here |
631 | 631 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
@@ -747,14 +747,14 @@ discard block |
||
747 | 747 | |
748 | 748 | |
749 | 749 | /** |
750 | - * load_controllers |
|
751 | - * |
|
752 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
753 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
754 | - * |
|
755 | - * @access public |
|
756 | - * @return void |
|
757 | - */ |
|
750 | + * load_controllers |
|
751 | + * |
|
752 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
753 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
754 | + * |
|
755 | + * @access public |
|
756 | + * @return void |
|
757 | + */ |
|
758 | 758 | public function load_controllers() { |
759 | 759 | do_action( 'AHEE__EE_System__load_controllers__start' ); |
760 | 760 | // let's get it started |
@@ -771,13 +771,13 @@ discard block |
||
771 | 771 | |
772 | 772 | |
773 | 773 | /** |
774 | - * core_loaded_and_ready |
|
775 | - * |
|
776 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
777 | - * |
|
778 | - * @access public |
|
779 | - * @return void |
|
780 | - */ |
|
774 | + * core_loaded_and_ready |
|
775 | + * |
|
776 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
777 | + * |
|
778 | + * @access public |
|
779 | + * @return void |
|
780 | + */ |
|
781 | 781 | public function core_loaded_and_ready() { |
782 | 782 | do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
783 | 783 | do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
@@ -788,13 +788,13 @@ discard block |
||
788 | 788 | |
789 | 789 | |
790 | 790 | /** |
791 | - * initialize |
|
792 | - * |
|
793 | - * this is the best place to begin initializing client code |
|
794 | - * |
|
795 | - * @access public |
|
796 | - * @return void |
|
797 | - */ |
|
791 | + * initialize |
|
792 | + * |
|
793 | + * this is the best place to begin initializing client code |
|
794 | + * |
|
795 | + * @access public |
|
796 | + * @return void |
|
797 | + */ |
|
798 | 798 | public function initialize() { |
799 | 799 | do_action( 'AHEE__EE_System__initialize' ); |
800 | 800 | } |
@@ -802,13 +802,13 @@ discard block |
||
802 | 802 | |
803 | 803 | |
804 | 804 | /** |
805 | - * initialize_last |
|
806 | - * |
|
807 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
808 | - * |
|
809 | - * @access public |
|
810 | - * @return void |
|
811 | - */ |
|
805 | + * initialize_last |
|
806 | + * |
|
807 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
808 | + * |
|
809 | + * @access public |
|
810 | + * @return void |
|
811 | + */ |
|
812 | 812 | public function initialize_last() { |
813 | 813 | do_action( 'AHEE__EE_System__initialize_last' ); |
814 | 814 | } |
@@ -817,14 +817,14 @@ discard block |
||
817 | 817 | |
818 | 818 | |
819 | 819 | /** |
820 | - * set_hooks_for_shortcodes_modules_and_addons |
|
821 | - * |
|
822 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
823 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
824 | - * |
|
825 | - * @access public |
|
826 | - * @return void |
|
827 | - */ |
|
820 | + * set_hooks_for_shortcodes_modules_and_addons |
|
821 | + * |
|
822 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
823 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
824 | + * |
|
825 | + * @access public |
|
826 | + * @return void |
|
827 | + */ |
|
828 | 828 | public function set_hooks_for_shortcodes_modules_and_addons() { |
829 | 829 | // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
830 | 830 | } |
@@ -833,13 +833,13 @@ discard block |
||
833 | 833 | |
834 | 834 | |
835 | 835 | /** |
836 | - * do_not_cache |
|
837 | - * |
|
838 | - * sets no cache headers and defines no cache constants for WP plugins |
|
839 | - * |
|
840 | - * @access public |
|
841 | - * @return void |
|
842 | - */ |
|
836 | + * do_not_cache |
|
837 | + * |
|
838 | + * sets no cache headers and defines no cache constants for WP plugins |
|
839 | + * |
|
840 | + * @access public |
|
841 | + * @return void |
|
842 | + */ |
|
843 | 843 | public static function do_not_cache() { |
844 | 844 | // set no cache constants |
845 | 845 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | //Current post |
958 | 958 | global $post; |
959 | 959 | |
960 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
960 | + if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
961 | 961 | //Events Edit Current Event |
962 | 962 | $admin_bar->add_menu(array( |
963 | 963 | 'id' => 'espresso-toolbar-events-edit', |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public static function instance() { |
104 | 104 | // check if class object is instantiated |
105 | - if ( ! self::$_instance instanceof EE_System ) { |
|
105 | + if ( ! self::$_instance instanceof EE_System) { |
|
106 | 106 | self::$_instance = new self(); |
107 | 107 | } |
108 | 108 | return self::$_instance; |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * resets the instance and returns it |
114 | 114 | * @return EE_System |
115 | 115 | */ |
116 | - public static function reset(){ |
|
116 | + public static function reset() { |
|
117 | 117 | self::$_instance->_req_type = NULL; |
118 | 118 | //we need to reset the migration manager in order for it to detect DMSs properly |
119 | 119 | EE_Data_Migration_Manager::reset(); |
120 | 120 | //make sure none of the old hooks are left hanging around |
121 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
121 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
122 | 122 | self::instance()->detect_activations_or_upgrades(); |
123 | 123 | self::instance()->perform_activations_upgrades_and_migrations(); |
124 | 124 | return self::instance(); |
@@ -134,26 +134,26 @@ discard block |
||
134 | 134 | * @access private |
135 | 135 | */ |
136 | 136 | private function __construct() { |
137 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
137 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
138 | 138 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
139 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) ); |
|
139 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
140 | 140 | // when an ee addon is activated, we want to call the core hook(s) again |
141 | 141 | // because the newly-activated addon didn't get a chance to run at all |
142 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
142 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
143 | 143 | // detect whether install or upgrade |
144 | - add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
144 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3); |
|
145 | 145 | // load EE_Config, EE_Textdomain, etc |
146 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 ); |
|
146 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
147 | 147 | // load EE_Config, EE_Textdomain, etc |
148 | - add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
148 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
149 | 149 | // you wanna get going? I wanna get going... let's get going! |
150 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 ); |
|
150 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
151 | 151 | //other housekeeping |
152 | 152 | //exclude EE critical pages from wp_list_pages |
153 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
153 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
154 | 154 | // ALL EE Addons should use the following hook point to attach their initial setup too |
155 | 155 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
156 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
156 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | public function load_espresso_addons() { |
174 | 174 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
175 | 175 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
176 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
176 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
177 | 177 | //load and setup EE_Capabilities |
178 | - EE_Registry::instance()->load_core( 'Capabilities' ); |
|
179 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
178 | + EE_Registry::instance()->load_core('Capabilities'); |
|
179 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | * @access public |
192 | 192 | * @return void |
193 | 193 | */ |
194 | - public function detect_activations_or_upgrades(){ |
|
194 | + public function detect_activations_or_upgrades() { |
|
195 | 195 | //first off: let's make sure to handle core |
196 | 196 | $this->detect_if_activation_or_upgrade(); |
197 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
197 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
198 | 198 | //detect teh request type for that addon |
199 | 199 | $addon->detect_activation_or_upgrade(); |
200 | 200 | } |
@@ -215,44 +215,44 @@ discard block |
||
215 | 215 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
216 | 216 | |
217 | 217 | // load M-Mode class |
218 | - EE_Registry::instance()->load_core( 'Maintenance_Mode' ); |
|
218 | + EE_Registry::instance()->load_core('Maintenance_Mode'); |
|
219 | 219 | // check if db has been updated, or if its a brand-new installation |
220 | 220 | |
221 | 221 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
222 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
222 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
223 | 223 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
224 | - if( $request_type != EE_System::req_type_normal){ |
|
224 | + if ($request_type != EE_System::req_type_normal) { |
|
225 | 225 | EE_Registry::instance()->load_helper('Activation'); |
226 | 226 | } |
227 | 227 | |
228 | - switch($request_type){ |
|
228 | + switch ($request_type) { |
|
229 | 229 | case EE_System::req_type_new_activation: |
230 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
231 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
230 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
231 | + $this->_handle_core_version_change($espresso_db_update); |
|
232 | 232 | break; |
233 | 233 | case EE_System::req_type_reactivation: |
234 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
235 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
234 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
235 | + $this->_handle_core_version_change($espresso_db_update); |
|
236 | 236 | break; |
237 | 237 | case EE_System::req_type_upgrade: |
238 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
238 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
239 | 239 | //migrations may be required now that we've upgraded |
240 | 240 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
241 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
241 | + $this->_handle_core_version_change($espresso_db_update); |
|
242 | 242 | // echo "done upgrade";die; |
243 | 243 | break; |
244 | 244 | case EE_System::req_type_downgrade: |
245 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
245 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
246 | 246 | //its possible migrations are no longer required |
247 | 247 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
248 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
248 | + $this->_handle_core_version_change($espresso_db_update); |
|
249 | 249 | break; |
250 | 250 | case EE_System::req_type_normal: |
251 | 251 | default: |
252 | 252 | // $this->_maybe_redirect_to_ee_about(); |
253 | 253 | break; |
254 | 254 | } |
255 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
255 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | * initializing the database later during the request |
261 | 261 | * @param array $espresso_db_update |
262 | 262 | */ |
263 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
264 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
263 | + protected function _handle_core_version_change($espresso_db_update) { |
|
264 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
265 | 265 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
266 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
266 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -278,44 +278,44 @@ discard block |
||
278 | 278 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
279 | 279 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
280 | 280 | */ |
281 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
282 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
283 | - if( ! $espresso_db_update){ |
|
284 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
281 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
282 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
283 | + if ( ! $espresso_db_update) { |
|
284 | + $espresso_db_update = get_option('espresso_db_update'); |
|
285 | 285 | } |
286 | 286 | // check that option is an array |
287 | - if( ! is_array( $espresso_db_update )) { |
|
287 | + if ( ! is_array($espresso_db_update)) { |
|
288 | 288 | // if option is FALSE, then it never existed |
289 | - if ( $espresso_db_update === FALSE ) { |
|
289 | + if ($espresso_db_update === FALSE) { |
|
290 | 290 | // make $espresso_db_update an array and save option with autoload OFF |
291 | - $espresso_db_update = array(); |
|
292 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
291 | + $espresso_db_update = array(); |
|
292 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
293 | 293 | } else { |
294 | 294 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
295 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
296 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
295 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
296 | + update_option('espresso_db_update', $espresso_db_update); |
|
297 | 297 | } |
298 | - }else{ |
|
298 | + } else { |
|
299 | 299 | $corrected_db_update = array(); |
300 | 300 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
301 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
302 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
301 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
302 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
303 | 303 | //the key is an int, and the value IS NOT an array |
304 | 304 | //so it must be numerically-indexed, where values are versions installed... |
305 | 305 | //fix it! |
306 | 306 | $version_string = $should_be_array; |
307 | 307 | $corrected_db_update[$version_string] = array('unknown-date'); |
308 | - }else{ |
|
308 | + } else { |
|
309 | 309 | //ok it checks out |
310 | 310 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
311 | 311 | } |
312 | 312 | } |
313 | 313 | $espresso_db_update = $corrected_db_update; |
314 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
314 | + update_option('espresso_db_update', $espresso_db_update); |
|
315 | 315 | |
316 | 316 | } |
317 | 317 | |
318 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
318 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
319 | 319 | return $espresso_db_update; |
320 | 320 | } |
321 | 321 | |
@@ -334,33 +334,33 @@ discard block |
||
334 | 334 | * so we prefer to only do it when necessary |
335 | 335 | * @return void |
336 | 336 | */ |
337 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
337 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
338 | 338 | $request_type = $this->detect_req_type(); |
339 | 339 | //only initialize system if we're not in maintenance mode. |
340 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
341 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
340 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
341 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
342 | 342 | EEH_Activation::system_initialization(); |
343 | - if( $verify_schema ) { |
|
343 | + if ($verify_schema) { |
|
344 | 344 | EEH_Activation::initialize_db_and_folders(); |
345 | 345 | } |
346 | 346 | EEH_Activation::initialize_db_content(); |
347 | - if( $initialize_addons_too ) { |
|
347 | + if ($initialize_addons_too) { |
|
348 | 348 | $this->initialize_addons(); |
349 | 349 | } |
350 | - }else{ |
|
351 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
350 | + } else { |
|
351 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
352 | 352 | } |
353 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
354 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
353 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
354 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Initializes the db for all registered addons |
360 | 360 | */ |
361 | - public function initialize_addons(){ |
|
361 | + public function initialize_addons() { |
|
362 | 362 | //foreach registered addon, make sure its db is up-to-date too |
363 | - foreach(EE_Registry::instance()->addons as $addon){ |
|
363 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
364 | 364 | $addon->initialize_db_if_no_migrations_required(); |
365 | 365 | } |
366 | 366 | } |
@@ -372,16 +372,16 @@ discard block |
||
372 | 372 | * @param string $current_version_to_add version to be added to the version history |
373 | 373 | * @return boolean success as to whether or not this option was changed |
374 | 374 | */ |
375 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
376 | - if( ! $version_history ) { |
|
375 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
376 | + if ( ! $version_history) { |
|
377 | 377 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
378 | 378 | } |
379 | - if( $current_version_to_add == NULL){ |
|
379 | + if ($current_version_to_add == NULL) { |
|
380 | 380 | $current_version_to_add = espresso_version(); |
381 | 381 | } |
382 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
382 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
383 | 383 | // re-save |
384 | - return update_option( 'espresso_db_update', $version_history ); |
|
384 | + return update_option('espresso_db_update', $version_history); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | * but still know if this is a new install or not |
399 | 399 | * @return int one of the constants on EE_System::req_type_ |
400 | 400 | */ |
401 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
402 | - if ( $this->_req_type === NULL ){ |
|
403 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
404 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
401 | + public function detect_req_type($espresso_db_update = NULL) { |
|
402 | + if ($this->_req_type === NULL) { |
|
403 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
404 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
405 | 405 | } |
406 | 406 | return $this->_req_type; |
407 | 407 | } |
@@ -417,39 +417,39 @@ discard block |
||
417 | 417 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
418 | 418 | * @return int one of the constants on EE_System::req_type_* |
419 | 419 | */ |
420 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
421 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
422 | - if( $activation_history_for_addon ){ |
|
420 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
421 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
422 | + if ($activation_history_for_addon) { |
|
423 | 423 | //it exists, so this isn't a completely new install |
424 | 424 | //check if this version already in that list of previously installed versions |
425 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
425 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
426 | 426 | //it a version we haven't seen before |
427 | - if( $version_is_higher === 1 ){ |
|
427 | + if ($version_is_higher === 1) { |
|
428 | 428 | $req_type = EE_System::req_type_upgrade; |
429 | - }else{ |
|
429 | + } else { |
|
430 | 430 | $req_type = EE_System::req_type_downgrade; |
431 | 431 | } |
432 | - delete_option( $activation_indicator_option_name ); |
|
432 | + delete_option($activation_indicator_option_name); |
|
433 | 433 | } else { |
434 | 434 | // its not an update. maybe a reactivation? |
435 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
436 | - if ( $version_is_higher === -1 ){ |
|
435 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
436 | + if ($version_is_higher === -1) { |
|
437 | 437 | $req_type = EE_System::req_type_downgrade; |
438 | - }elseif( $version_is_higher === 0 ){ |
|
438 | + }elseif ($version_is_higher === 0) { |
|
439 | 439 | //we've seen this version before, but it's an activation. must be a reactivation |
440 | 440 | $req_type = EE_System::req_type_reactivation; |
441 | - }else{//$version_is_higher === 1 |
|
441 | + } else {//$version_is_higher === 1 |
|
442 | 442 | $req_type = EE_System::req_type_upgrade; |
443 | 443 | } |
444 | - delete_option( $activation_indicator_option_name ); |
|
444 | + delete_option($activation_indicator_option_name); |
|
445 | 445 | } else { |
446 | 446 | //we've seen this version before and the activation indicate doesn't show it was just activated |
447 | - if ( $version_is_higher === -1 ){ |
|
447 | + if ($version_is_higher === -1) { |
|
448 | 448 | $req_type = EE_System::req_type_downgrade; |
449 | - }elseif( $version_is_higher === 0 ){ |
|
449 | + }elseif ($version_is_higher === 0) { |
|
450 | 450 | //we've seen this version before and it's not an activation. its normal request |
451 | 451 | $req_type = EE_System::req_type_normal; |
452 | - }else{//$version_is_higher === 1 |
|
452 | + } else {//$version_is_higher === 1 |
|
453 | 453 | $req_type = EE_System::req_type_upgrade; |
454 | 454 | } |
455 | 455 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | } else { |
458 | 458 | //brand new install |
459 | 459 | $req_type = EE_System::req_type_new_activation; |
460 | - delete_option( $activation_indicator_option_name ); |
|
460 | + delete_option($activation_indicator_option_name); |
|
461 | 461 | } |
462 | 462 | return $req_type; |
463 | 463 | } |
@@ -475,30 +475,30 @@ discard block |
||
475 | 475 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
476 | 476 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
477 | 477 | */ |
478 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
478 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
479 | 479 | //find the most recently-activated version |
480 | 480 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
481 | 481 | $most_recently_active_version = '0.0.0.dev.000'; |
482 | - if( is_array( $activation_history_for_addon ) ){ |
|
483 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
482 | + if (is_array($activation_history_for_addon)) { |
|
483 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
484 | 484 | //check there is a record of when this version was activated. Otherwise, |
485 | 485 | //mark it as unknown |
486 | - if( ! $times_activated ){ |
|
487 | - $times_activated = array( 'unknown-date'); |
|
486 | + if ( ! $times_activated) { |
|
487 | + $times_activated = array('unknown-date'); |
|
488 | 488 | } |
489 | - if( is_string( $times_activated ) ){ |
|
490 | - $times_activated = array( $times_activated ); |
|
489 | + if (is_string($times_activated)) { |
|
490 | + $times_activated = array($times_activated); |
|
491 | 491 | } |
492 | - foreach( $times_activated as $an_activation ){ |
|
493 | - if( $an_activation != 'unknown-date' && |
|
494 | - $an_activation > $most_recently_active_version_activation ){ |
|
492 | + foreach ($times_activated as $an_activation) { |
|
493 | + if ($an_activation != 'unknown-date' && |
|
494 | + $an_activation > $most_recently_active_version_activation) { |
|
495 | 495 | $most_recently_active_version = $version; |
496 | 496 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | 500 | } |
501 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
501 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | |
@@ -508,20 +508,20 @@ discard block |
||
508 | 508 | * @return void |
509 | 509 | */ |
510 | 510 | public function redirect_to_about_ee() { |
511 | - $notices = EE_Error::get_notices( FALSE ); |
|
511 | + $notices = EE_Error::get_notices(FALSE); |
|
512 | 512 | //if current user is an admin and it's not an ajax request |
513 | - if(EE_Registry::instance()->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) && ! ( defined('DOING_AJAX') && DOING_AJAX ) && ! isset( $notices[ 'errors' ] ) ){ |
|
514 | - $query_params = array( 'page' => 'espresso_about' ); |
|
513 | + if (EE_Registry::instance()->CAP->current_user_can('manage_options', 'espresso_about_default') && ! (defined('DOING_AJAX') && DOING_AJAX) && ! isset($notices['errors'])) { |
|
514 | + $query_params = array('page' => 'espresso_about'); |
|
515 | 515 | |
516 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
516 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
517 | 517 | $query_params['new_activation'] = TRUE; |
518 | 518 | } |
519 | 519 | |
520 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
520 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
521 | 521 | $query_params['reactivation'] = TRUE; |
522 | 522 | } |
523 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
524 | - wp_safe_redirect( $url ); |
|
523 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
524 | + wp_safe_redirect($url); |
|
525 | 525 | exit(); |
526 | 526 | } |
527 | 527 | } |
@@ -535,31 +535,31 @@ discard block |
||
535 | 535 | * |
536 | 536 | * @return void |
537 | 537 | */ |
538 | - public function load_core_configuration(){ |
|
539 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
540 | - EE_Registry::instance()->load_core( 'EE_Load_Textdomain' ); |
|
538 | + public function load_core_configuration() { |
|
539 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
540 | + EE_Registry::instance()->load_core('EE_Load_Textdomain'); |
|
541 | 541 | //load textdomain |
542 | 542 | EE_Load_Textdomain::load_textdomain(); |
543 | 543 | // load and setup EE_Config and EE_Network_Config |
544 | - EE_Registry::instance()->load_core( 'Config' ); |
|
545 | - EE_Registry::instance()->load_core( 'Network_Config' ); |
|
544 | + EE_Registry::instance()->load_core('Config'); |
|
545 | + EE_Registry::instance()->load_core('Network_Config'); |
|
546 | 546 | // setup autoloaders |
547 | 547 | // enable logging? |
548 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
549 | - EE_Registry::instance()->load_core( 'Log' ); |
|
548 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
549 | + EE_Registry::instance()->load_core('Log'); |
|
550 | 550 | } |
551 | 551 | // check for activation errors |
552 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
553 | - if ( $activation_errors ) { |
|
554 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
555 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
552 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
553 | + if ($activation_errors) { |
|
554 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
555 | + update_option('ee_plugin_activation_errors', FALSE); |
|
556 | 556 | } |
557 | 557 | // get model names |
558 | 558 | $this->_parse_model_names(); |
559 | 559 | |
560 | 560 | //load caf stuff a chance to play during the activation process too. |
561 | 561 | $this->_maybe_brew_regular(); |
562 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
562 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | |
@@ -568,23 +568,23 @@ discard block |
||
568 | 568 | * |
569 | 569 | * @return void |
570 | 570 | */ |
571 | - private function _parse_model_names(){ |
|
571 | + private function _parse_model_names() { |
|
572 | 572 | //get all the files in the EE_MODELS folder that end in .model.php |
573 | - $models = glob( EE_MODELS.'*.model.php'); |
|
573 | + $models = glob(EE_MODELS.'*.model.php'); |
|
574 | 574 | $model_names = array(); |
575 | 575 | $non_abstract_db_models = array(); |
576 | - foreach( $models as $model ){ |
|
576 | + foreach ($models as $model) { |
|
577 | 577 | // get model classname |
578 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
579 | - $shortname = str_replace( 'EEM_', '', $classname ); |
|
578 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
579 | + $shortname = str_replace('EEM_', '', $classname); |
|
580 | 580 | $reflectionClass = new ReflectionClass($classname); |
581 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
581 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
582 | 582 | $non_abstract_db_models[$shortname] = $classname; |
583 | 583 | } |
584 | - $model_names[ $shortname ] = $classname; |
|
584 | + $model_names[$shortname] = $classname; |
|
585 | 585 | } |
586 | - EE_Registry::instance()->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
587 | - EE_Registry::instance()->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
586 | + EE_Registry::instance()->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
587 | + EE_Registry::instance()->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | |
@@ -594,8 +594,8 @@ discard block |
||
594 | 594 | * @return void |
595 | 595 | */ |
596 | 596 | private function _maybe_brew_regular() { |
597 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
598 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
597 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
598 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
@@ -612,9 +612,9 @@ discard block |
||
612 | 612 | * @return void |
613 | 613 | */ |
614 | 614 | public function register_shortcodes_modules_and_widgets() { |
615 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
615 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
616 | 616 | // check for addons using old hookpoint |
617 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
617 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
618 | 618 | $this->_incompatible_addon_error(); |
619 | 619 | } |
620 | 620 | } |
@@ -628,19 +628,19 @@ discard block |
||
628 | 628 | */ |
629 | 629 | private function _incompatible_addon_error() { |
630 | 630 | // get array of classes hooking into here |
631 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
632 | - if ( ! empty( $class_names )) { |
|
633 | - $msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' ); |
|
631 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
632 | + if ( ! empty($class_names)) { |
|
633 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso'); |
|
634 | 634 | $msg .= '<ul>'; |
635 | - foreach ( $class_names as $class_name ) { |
|
636 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
635 | + foreach ($class_names as $class_name) { |
|
636 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
637 | 637 | } |
638 | 638 | $msg .= '</ul>'; |
639 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
639 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
640 | 640 | // save list of incompatible addons to wp-options for later use |
641 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
642 | - if ( is_admin() ) { |
|
643 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
641 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
642 | + if (is_admin()) { |
|
643 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
644 | 644 | } |
645 | 645 | } |
646 | 646 | } |
@@ -657,25 +657,25 @@ discard block |
||
657 | 657 | * |
658 | 658 | * @return void |
659 | 659 | */ |
660 | - public function brew_espresso(){ |
|
661 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
660 | + public function brew_espresso() { |
|
661 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
662 | 662 | // load some final core systems |
663 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
664 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
665 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
666 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
667 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
668 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
669 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
670 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
671 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
672 | - |
|
673 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
663 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
664 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
665 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
666 | + add_action('init', array($this, 'load_controllers'), 7); |
|
667 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
668 | + add_action('init', array($this, 'initialize'), 10); |
|
669 | + add_action('init', array($this, 'initialize_last'), 100); |
|
670 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
671 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
672 | + |
|
673 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
674 | 674 | // pew pew pew |
675 | - EE_Registry::instance()->load_core( 'PUE' ); |
|
676 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
675 | + EE_Registry::instance()->load_core('PUE'); |
|
676 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
677 | 677 | } |
678 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
678 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | */ |
690 | 690 | public function set_hooks_for_core() { |
691 | 691 | $this->_deactivate_incompatible_addons(); |
692 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
692 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | |
@@ -698,15 +698,15 @@ discard block |
||
698 | 698 | * Using the information gathered in EE_System::_incompatible_addon_error, |
699 | 699 | * deactivates any addons considered incompatible with the current version of EE |
700 | 700 | */ |
701 | - private function _deactivate_incompatible_addons(){ |
|
702 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
703 | - if ( ! empty( $incompatible_addons )) { |
|
704 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
705 | - foreach ( $active_plugins as $active_plugin ) { |
|
706 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
707 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
708 | - unset( $_GET['activate'] ); |
|
709 | - espresso_deactivate_plugin( $active_plugin ); |
|
701 | + private function _deactivate_incompatible_addons() { |
|
702 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
703 | + if ( ! empty($incompatible_addons)) { |
|
704 | + $active_plugins = get_option('active_plugins', array()); |
|
705 | + foreach ($active_plugins as $active_plugin) { |
|
706 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
707 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
708 | + unset($_GET['activate']); |
|
709 | + espresso_deactivate_plugin($active_plugin); |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | } |
@@ -723,10 +723,10 @@ discard block |
||
723 | 723 | */ |
724 | 724 | public function perform_activations_upgrades_and_migrations() { |
725 | 725 | //first check if we had previously attempted to setup EE's directories but failed |
726 | - if( EEH_Activation::upload_directories_incomplete() ) { |
|
726 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
727 | 727 | EEH_Activation::create_upload_directories(); |
728 | 728 | } |
729 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
729 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | |
@@ -738,10 +738,10 @@ discard block |
||
738 | 738 | * @return void |
739 | 739 | */ |
740 | 740 | public function load_CPTs_and_session() { |
741 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
741 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
742 | 742 | // register Custom Post Types |
743 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
744 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
743 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
744 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | |
@@ -756,16 +756,16 @@ discard block |
||
756 | 756 | * @return void |
757 | 757 | */ |
758 | 758 | public function load_controllers() { |
759 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
759 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
760 | 760 | // let's get it started |
761 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
762 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
763 | - EE_Registry::instance()->load_core( 'Front_Controller' ); |
|
764 | - } else if ( ! EE_FRONT_AJAX ) { |
|
765 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
766 | - EE_Registry::instance()->load_core( 'Admin' ); |
|
761 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
762 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
763 | + EE_Registry::instance()->load_core('Front_Controller'); |
|
764 | + } else if ( ! EE_FRONT_AJAX) { |
|
765 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
766 | + EE_Registry::instance()->load_core('Admin'); |
|
767 | 767 | } |
768 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
768 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | |
@@ -779,10 +779,10 @@ discard block |
||
779 | 779 | * @return void |
780 | 780 | */ |
781 | 781 | public function core_loaded_and_ready() { |
782 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
783 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
782 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
783 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
784 | 784 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
785 | - EE_Registry::instance()->load_core( 'Session' ); |
|
785 | + EE_Registry::instance()->load_core('Session'); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * @return void |
797 | 797 | */ |
798 | 798 | public function initialize() { |
799 | - do_action( 'AHEE__EE_System__initialize' ); |
|
799 | + do_action('AHEE__EE_System__initialize'); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | * @return void |
811 | 811 | */ |
812 | 812 | public function initialize_last() { |
813 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
813 | + do_action('AHEE__EE_System__initialize_last'); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | |
@@ -842,21 +842,21 @@ discard block |
||
842 | 842 | */ |
843 | 843 | public static function do_not_cache() { |
844 | 844 | // set no cache constants |
845 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
846 | - define( 'DONOTCACHEPAGE', true ); |
|
845 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
846 | + define('DONOTCACHEPAGE', true); |
|
847 | 847 | } |
848 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
849 | - define( 'DONOTCACHCEOBJECT', true ); |
|
848 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
849 | + define('DONOTCACHCEOBJECT', true); |
|
850 | 850 | } |
851 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
852 | - define( 'DONOTCACHEDB', true ); |
|
851 | + if ( ! defined('DONOTCACHEDB')) { |
|
852 | + define('DONOTCACHEDB', true); |
|
853 | 853 | } |
854 | 854 | // add no cache headers |
855 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
855 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
856 | 856 | // plus a little extra for nginx |
857 | - add_filter( 'nocache_headers', array( 'EE_System', 'nocache_headers_nginx' ), 10, 1 ); |
|
857 | + add_filter('nocache_headers', array('EE_System', 'nocache_headers_nginx'), 10, 1); |
|
858 | 858 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
859 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
859 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | * @param $headers |
869 | 869 | * @return array |
870 | 870 | */ |
871 | - public static function nocache_headers_nginx ( $headers ) { |
|
871 | + public static function nocache_headers_nginx($headers) { |
|
872 | 872 | $headers['X-Accel-Expires'] = 0; |
873 | 873 | return $headers; |
874 | 874 | } |
@@ -894,15 +894,15 @@ discard block |
||
894 | 894 | * @param $admin_bar |
895 | 895 | * @return void |
896 | 896 | */ |
897 | - public function espresso_toolbar_items( $admin_bar ) { |
|
897 | + public function espresso_toolbar_items($admin_bar) { |
|
898 | 898 | |
899 | 899 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
900 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
|
900 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { |
|
901 | 901 | return; |
902 | 902 | } |
903 | 903 | |
904 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
905 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
904 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
905 | + EE_Registry::instance()->load_helper('URL'); |
|
906 | 906 | $menu_class = 'espresso_menu_item_class'; |
907 | 907 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
908 | 908 | //because they're only defined in each of their respective constructors |
@@ -914,20 +914,20 @@ discard block |
||
914 | 914 | //Top Level |
915 | 915 | $admin_bar->add_menu(array( |
916 | 916 | 'id' => 'espresso-toolbar', |
917 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', |
|
917 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>', |
|
918 | 918 | 'href' => $events_admin_url, |
919 | 919 | 'meta' => array( |
920 | 920 | 'title' => __('Event Espresso', 'event_espresso'), |
921 | - 'class' => $menu_class . 'first' |
|
921 | + 'class' => $menu_class.'first' |
|
922 | 922 | ), |
923 | 923 | )); |
924 | 924 | |
925 | 925 | //Events |
926 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
926 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
927 | 927 | $admin_bar->add_menu(array( |
928 | 928 | 'id' => 'espresso-toolbar-events', |
929 | 929 | 'parent' => 'espresso-toolbar', |
930 | - 'title' => __( 'Events', 'event_espresso' ), |
|
930 | + 'title' => __('Events', 'event_espresso'), |
|
931 | 931 | 'href' => $events_admin_url, |
932 | 932 | 'meta' => array( |
933 | 933 | 'title' => __('Events', 'event_espresso'), |
@@ -938,13 +938,13 @@ discard block |
||
938 | 938 | } |
939 | 939 | |
940 | 940 | |
941 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
941 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
942 | 942 | //Events Add New |
943 | 943 | $admin_bar->add_menu(array( |
944 | 944 | 'id' => 'espresso-toolbar-events-new', |
945 | 945 | 'parent' => 'espresso-toolbar-events', |
946 | 946 | 'title' => __('Add New', 'event_espresso'), |
947 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
947 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
948 | 948 | 'meta' => array( |
949 | 949 | 'title' => __('Add New', 'event_espresso'), |
950 | 950 | 'target' => '', |
@@ -953,18 +953,18 @@ discard block |
||
953 | 953 | )); |
954 | 954 | } |
955 | 955 | |
956 | - if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
|
956 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
957 | 957 | |
958 | 958 | //Current post |
959 | 959 | global $post; |
960 | 960 | |
961 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
961 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { |
|
962 | 962 | //Events Edit Current Event |
963 | 963 | $admin_bar->add_menu(array( |
964 | 964 | 'id' => 'espresso-toolbar-events-edit', |
965 | 965 | 'parent' => 'espresso-toolbar-events', |
966 | 966 | 'title' => __('Edit Event', 'event_espresso'), |
967 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
|
967 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url), |
|
968 | 968 | 'meta' => array( |
969 | 969 | 'title' => __('Edit Event', 'event_espresso'), |
970 | 970 | 'target' => '', |
@@ -976,11 +976,11 @@ discard block |
||
976 | 976 | } |
977 | 977 | |
978 | 978 | //Events View |
979 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
979 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
980 | 980 | $admin_bar->add_menu(array( |
981 | 981 | 'id' => 'espresso-toolbar-events-view', |
982 | 982 | 'parent' => 'espresso-toolbar-events', |
983 | - 'title' => __( 'View', 'event_espresso' ), |
|
983 | + 'title' => __('View', 'event_espresso'), |
|
984 | 984 | 'href' => $events_admin_url, |
985 | 985 | 'meta' => array( |
986 | 986 | 'title' => __('View', 'event_espresso'), |
@@ -990,12 +990,12 @@ discard block |
||
990 | 990 | )); |
991 | 991 | } |
992 | 992 | |
993 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
993 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
994 | 994 | //Events View All |
995 | 995 | $admin_bar->add_menu(array( |
996 | 996 | 'id' => 'espresso-toolbar-events-all', |
997 | 997 | 'parent' => 'espresso-toolbar-events-view', |
998 | - 'title' => __( 'All', 'event_espresso' ), |
|
998 | + 'title' => __('All', 'event_espresso'), |
|
999 | 999 | 'href' => $events_admin_url, |
1000 | 1000 | 'meta' => array( |
1001 | 1001 | 'title' => __('All', 'event_espresso'), |
@@ -1006,13 +1006,13 @@ discard block |
||
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | |
1009 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1009 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1010 | 1010 | //Events View Today |
1011 | 1011 | $admin_bar->add_menu(array( |
1012 | 1012 | 'id' => 'espresso-toolbar-events-today', |
1013 | 1013 | 'parent' => 'espresso-toolbar-events-view', |
1014 | 1014 | 'title' => __('Today', 'event_espresso'), |
1015 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1015 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1016 | 1016 | 'meta' => array( |
1017 | 1017 | 'title' => __('Today', 'event_espresso'), |
1018 | 1018 | 'target' => '', |
@@ -1022,13 +1022,13 @@ discard block |
||
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | |
1025 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1025 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1026 | 1026 | //Events View This Month |
1027 | 1027 | $admin_bar->add_menu(array( |
1028 | 1028 | 'id' => 'espresso-toolbar-events-month', |
1029 | 1029 | 'parent' => 'espresso-toolbar-events-view', |
1030 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1031 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1030 | + 'title' => __('This Month', 'event_espresso'), |
|
1031 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1032 | 1032 | 'meta' => array( |
1033 | 1033 | 'title' => __('This Month', 'event_espresso'), |
1034 | 1034 | 'target' => '', |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | //Registration Overview |
1041 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1041 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1042 | 1042 | $admin_bar->add_menu(array( |
1043 | 1043 | 'id' => 'espresso-toolbar-registrations', |
1044 | 1044 | 'parent' => 'espresso-toolbar', |
1045 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1045 | + 'title' => __('Registrations', 'event_espresso'), |
|
1046 | 1046 | 'href' => $reg_admin_url, |
1047 | 1047 | 'meta' => array( |
1048 | 1048 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1053,12 +1053,12 @@ discard block |
||
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | //Registration Overview Today |
1056 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1056 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1057 | 1057 | $admin_bar->add_menu(array( |
1058 | 1058 | 'id' => 'espresso-toolbar-registrations-today', |
1059 | 1059 | 'parent' => 'espresso-toolbar-registrations', |
1060 | - 'title' => __( 'Today', 'event_espresso'), |
|
1061 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1060 | + 'title' => __('Today', 'event_espresso'), |
|
1061 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1062 | 1062 | 'meta' => array( |
1063 | 1063 | 'title' => __('Today', 'event_espresso'), |
1064 | 1064 | 'target' => '', |
@@ -1068,14 +1068,14 @@ discard block |
||
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | //Registration Overview Today Completed |
1071 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1071 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1072 | 1072 | $admin_bar->add_menu(array( |
1073 | 1073 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1074 | 1074 | 'parent' => 'espresso-toolbar-registrations-today', |
1075 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1076 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1075 | + 'title' => __('Approved', 'event_espresso'), |
|
1076 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1077 | 1077 | 'meta' => array( |
1078 | - 'title' => __('Approved', 'event_espresso' ), |
|
1078 | + 'title' => __('Approved', 'event_espresso'), |
|
1079 | 1079 | 'target' => '', |
1080 | 1080 | 'class' => $menu_class |
1081 | 1081 | ), |
@@ -1083,14 +1083,14 @@ discard block |
||
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | //Registration Overview Today Pending\ |
1086 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1086 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1087 | 1087 | $admin_bar->add_menu(array( |
1088 | 1088 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1089 | 1089 | 'parent' => 'espresso-toolbar-registrations-today', |
1090 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1091 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1090 | + 'title' => __('Pending', 'event_espresso'), |
|
1091 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1092 | 1092 | 'meta' => array( |
1093 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1093 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1094 | 1094 | 'target' => '', |
1095 | 1095 | 'class' => $menu_class |
1096 | 1096 | ), |
@@ -1098,14 +1098,14 @@ discard block |
||
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | //Registration Overview Today Incomplete |
1101 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1101 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1102 | 1102 | $admin_bar->add_menu(array( |
1103 | 1103 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1104 | 1104 | 'parent' => 'espresso-toolbar-registrations-today', |
1105 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1106 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1105 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1106 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1107 | 1107 | 'meta' => array( |
1108 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1108 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1109 | 1109 | 'target' => '', |
1110 | 1110 | 'class' => $menu_class |
1111 | 1111 | ), |
@@ -1113,12 +1113,12 @@ discard block |
||
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | //Registration Overview Today Incomplete |
1116 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1116 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1117 | 1117 | $admin_bar->add_menu(array( |
1118 | 1118 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1119 | 1119 | 'parent' => 'espresso-toolbar-registrations-today', |
1120 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1121 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1120 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1121 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1122 | 1122 | 'meta' => array( |
1123 | 1123 | 'title' => __('Cancelled', 'event_espresso'), |
1124 | 1124 | 'target' => '', |
@@ -1128,12 +1128,12 @@ discard block |
||
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | //Registration Overview This Month |
1131 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1131 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1132 | 1132 | $admin_bar->add_menu(array( |
1133 | 1133 | 'id' => 'espresso-toolbar-registrations-month', |
1134 | 1134 | 'parent' => 'espresso-toolbar-registrations', |
1135 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1136 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1135 | + 'title' => __('This Month', 'event_espresso'), |
|
1136 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1137 | 1137 | 'meta' => array( |
1138 | 1138 | 'title' => __('This Month', 'event_espresso'), |
1139 | 1139 | 'target' => '', |
@@ -1143,12 +1143,12 @@ discard block |
||
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | //Registration Overview This Month Approved |
1146 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1146 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1147 | 1147 | $admin_bar->add_menu(array( |
1148 | 1148 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1149 | 1149 | 'parent' => 'espresso-toolbar-registrations-month', |
1150 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1151 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1150 | + 'title' => __('Approved', 'event_espresso'), |
|
1151 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1152 | 1152 | 'meta' => array( |
1153 | 1153 | 'title' => __('Approved', 'event_espresso'), |
1154 | 1154 | 'target' => '', |
@@ -1158,12 +1158,12 @@ discard block |
||
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | //Registration Overview This Month Pending |
1161 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1161 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1162 | 1162 | $admin_bar->add_menu(array( |
1163 | 1163 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1164 | 1164 | 'parent' => 'espresso-toolbar-registrations-month', |
1165 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1166 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1165 | + 'title' => __('Pending', 'event_espresso'), |
|
1166 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1167 | 1167 | 'meta' => array( |
1168 | 1168 | 'title' => __('Pending', 'event_espresso'), |
1169 | 1169 | 'target' => '', |
@@ -1173,14 +1173,14 @@ discard block |
||
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | //Registration Overview This Month Not Approved |
1176 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1176 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1177 | 1177 | $admin_bar->add_menu(array( |
1178 | 1178 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1179 | 1179 | 'parent' => 'espresso-toolbar-registrations-month', |
1180 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1181 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1180 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1181 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1182 | 1182 | 'meta' => array( |
1183 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1183 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1184 | 1184 | 'target' => '', |
1185 | 1185 | 'class' => $menu_class |
1186 | 1186 | ), |
@@ -1189,12 +1189,12 @@ discard block |
||
1189 | 1189 | |
1190 | 1190 | |
1191 | 1191 | //Registration Overview This Month Cancelled |
1192 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1192 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1193 | 1193 | $admin_bar->add_menu(array( |
1194 | 1194 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1195 | 1195 | 'parent' => 'espresso-toolbar-registrations-month', |
1196 | 1196 | 'title' => __('Cancelled', 'event_espresso'), |
1197 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1197 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1198 | 1198 | 'meta' => array( |
1199 | 1199 | 'title' => __('Cancelled', 'event_espresso'), |
1200 | 1200 | 'target' => '', |
@@ -1204,11 +1204,11 @@ discard block |
||
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | //Extensions & Services |
1207 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1207 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { |
|
1208 | 1208 | $admin_bar->add_menu(array( |
1209 | 1209 | 'id' => 'espresso-toolbar-extensions-and-services', |
1210 | 1210 | 'parent' => 'espresso-toolbar', |
1211 | - 'title' => __( 'Extensions & Services', 'event_espresso' ), |
|
1211 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1212 | 1212 | 'href' => $extensions_admin_url, |
1213 | 1213 | 'meta' => array( |
1214 | 1214 | 'title' => __('Extensions & Services', 'event_espresso'), |
@@ -1230,8 +1230,8 @@ discard block |
||
1230 | 1230 | * @param array $exclude_array any existing pages being excluded are in this array. |
1231 | 1231 | * @return array |
1232 | 1232 | */ |
1233 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1234 | - return array_merge( $exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array() ); |
|
1233 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1234 | + return array_merge($exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array()); |
|
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | |
@@ -1251,11 +1251,11 @@ discard block |
||
1251 | 1251 | */ |
1252 | 1252 | public function wp_enqueue_scripts() { |
1253 | 1253 | // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
1254 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1254 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1255 | 1255 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1256 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1256 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1257 | 1257 | // register jQuery Validate |
1258 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE ); |
|
1258 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE); |
|
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | } |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @param mixed $opt_group |
776 | 776 | * @param mixed $QSOs |
777 | - * @param mixed $answer |
|
777 | + * @param string $answer |
|
778 | 778 | * @return string |
779 | 779 | */ |
780 | 780 | private static function _generate_select_option_group( $opt_group, $QSOs, $answer ){ |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | /** |
1123 | 1123 | * prep_required |
1124 | 1124 | * @param string|array $required |
1125 | - * @return array |
|
1125 | + * @return string |
|
1126 | 1126 | */ |
1127 | 1127 | static function prep_required( $required = array() ){ |
1128 | 1128 | // make sure required is an array |
@@ -1173,8 +1173,8 @@ discard block |
||
1173 | 1173 | |
1174 | 1174 | /** |
1175 | 1175 | * _load_system_dropdowns |
1176 | - * @param array $QFI |
|
1177 | - * @return array |
|
1176 | + * @param EE_Question_Form_Input $QFI |
|
1177 | + * @return EE_Question_Form_Input |
|
1178 | 1178 | */ |
1179 | 1179 | private static function _load_system_dropdowns( $QFI ){ |
1180 | 1180 | $QST_system = $QFI->get('QST_system'); |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | * @param string $nonce_action - if using nonces |
1464 | 1464 | * @param bool|string $input_only - whether to print form header and footer. TRUE returns the input without the form |
1465 | 1465 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1466 | - * @return void |
|
1466 | + * @return string |
|
1467 | 1467 | */ |
1468 | 1468 | public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
1469 | 1469 | $btn = ''; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | |
394 | 394 | /** |
395 | 395 | * generate_question_groups_html |
396 | - * |
|
396 | + * |
|
397 | 397 | * @param string $question_groups |
398 | 398 | * @return string HTML |
399 | 399 | */ |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | |
538 | 538 | /** |
539 | 539 | * generate_form_input |
540 | - * |
|
540 | + * |
|
541 | 541 | * @param EE_Question_Form_Input $QFI |
542 | 542 | * @return string HTML |
543 | 543 | */ |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | /** |
614 | 614 | * generates HTML for a form text input |
615 | - * |
|
615 | + * |
|
616 | 616 | * @param string $question label content |
617 | 617 | * @param string $answer form input value attribute |
618 | 618 | * @param string $name form input name attribute |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | |
658 | 658 | /** |
659 | 659 | * generates HTML for a form textarea |
660 | - * |
|
660 | + * |
|
661 | 661 | * @param string $question label content |
662 | 662 | * @param string $answer form input value attribute |
663 | 663 | * @param string $name form input name attribute |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | /** |
710 | 710 | * generates HTML for a form select input |
711 | - * |
|
711 | + * |
|
712 | 712 | * @param string $question label content |
713 | 713 | * @param string $answer form input value attribute |
714 | 714 | * @param array $options array of answer options where array key = option value and array value = option display text |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | |
886 | 886 | /** |
887 | 887 | * generates HTML for form checkbox inputs |
888 | - * |
|
888 | + * |
|
889 | 889 | * @param string $question label content |
890 | 890 | * @param string $answer form input value attribute |
891 | 891 | * @param array $options array of options where array key = option value and array value = option display text |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | |
967 | 967 | /** |
968 | 968 | * generates HTML for a form datepicker input |
969 | - * |
|
969 | + * |
|
970 | 970 | * @param string $question label content |
971 | 971 | * @param string $answer form input value attribute |
972 | 972 | * @param string $name form input name attribute |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | * @return string |
59 | 59 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
60 | 60 | */ |
61 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
61 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
62 | 62 | |
63 | - if ( empty($input_vars) ) { |
|
64 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
63 | + if (empty($input_vars)) { |
|
64 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
65 | 65 | return FALSE; |
66 | 66 | } |
67 | 67 | |
@@ -87,25 +87,25 @@ discard block |
||
87 | 87 | 'append_content' => '' |
88 | 88 | ); |
89 | 89 | |
90 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
90 | + $input_value = wp_parse_args($input_value, $defaults); |
|
91 | 91 | |
92 | 92 | // required fields get a * |
93 | 93 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
94 | 94 | // and the css class "required" |
95 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
96 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
95 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
96 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
97 | 97 | |
98 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
99 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
98 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
99 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
100 | 100 | |
101 | 101 | //rows or cols? |
102 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
103 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
102 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
103 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
104 | 104 | |
105 | 105 | //any content? |
106 | 106 | $append_content = $input_value['append_content']; |
107 | 107 | |
108 | - $output .= (!$close) ? '<ul>' : ''; |
|
108 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
109 | 109 | $output .= '<li>'; |
110 | 110 | |
111 | 111 | // what type of input are we dealing with ? |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | |
114 | 114 | // text inputs |
115 | 115 | case 'text' : |
116 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
117 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . $input_value['value'] . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
116 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
117 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.$input_value['value'].'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
118 | 118 | break; |
119 | 119 | |
120 | 120 | // dropdowns |
121 | 121 | case 'select' : |
122 | 122 | |
123 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
124 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
123 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
124 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
125 | 125 | |
126 | 126 | if (is_array($input_value['options'])) { |
127 | 127 | $options = $input_value['options']; |
@@ -130,30 +130,30 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | foreach ($options as $key => $value) { |
133 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
133 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
134 | 134 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
135 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
135 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
136 | 136 | } |
137 | - $output .= "\n\t\t\t" . '</select>'; |
|
137 | + $output .= "\n\t\t\t".'</select>'; |
|
138 | 138 | |
139 | 139 | break; |
140 | 140 | |
141 | 141 | case 'textarea' : |
142 | 142 | |
143 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
144 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . $input_value['value'] . '</textarea>'; |
|
143 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
144 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.$input_value['value'].'</textarea>'; |
|
145 | 145 | break; |
146 | 146 | |
147 | 147 | case 'hidden' : |
148 | 148 | $close = false; |
149 | 149 | $output .= "</li></ul>"; |
150 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
150 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
151 | 151 | break; |
152 | 152 | |
153 | 153 | case 'checkbox' : |
154 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
155 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
156 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
154 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
155 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
156 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
157 | 157 | break; |
158 | 158 | |
159 | 159 | case 'wp_editor' : |
@@ -166,19 +166,19 @@ discard block |
||
166 | 166 | ); |
167 | 167 | $output .= '</li>'; |
168 | 168 | $output .= '</ul>'; |
169 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
170 | - if ( $append_content ) { |
|
169 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
170 | + if ($append_content) { |
|
171 | 171 | $output .= $append_content; |
172 | 172 | } |
173 | 173 | ob_start(); |
174 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
174 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
175 | 175 | $editor = ob_get_contents(); |
176 | 176 | ob_end_clean(); |
177 | 177 | $output .= $editor; |
178 | 178 | break; |
179 | 179 | |
180 | 180 | } |
181 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
181 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | $output .= ($close) ? '</li>' : ''; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $form_fields = array(); |
220 | 220 | $fields = (array) $fields; |
221 | 221 | |
222 | - foreach ( $fields as $field_name => $field_atts ) { |
|
222 | + foreach ($fields as $field_name => $field_atts) { |
|
223 | 223 | //defaults: |
224 | 224 | $defaults = array( |
225 | 225 | 'label' => '', |
@@ -237,67 +237,67 @@ discard block |
||
237 | 237 | 'wpeditor_args' => array() |
238 | 238 | ); |
239 | 239 | // merge defaults with passed arguments |
240 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
241 | - extract( $_fields ); |
|
240 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
241 | + extract($_fields); |
|
242 | 242 | // generate label |
243 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
243 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
244 | 244 | // generate field name |
245 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
245 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
246 | 246 | |
247 | 247 | //tabindex |
248 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
248 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
249 | 249 | |
250 | 250 | //we determine what we're building based on the type |
251 | - switch ( $type ) { |
|
251 | + switch ($type) { |
|
252 | 252 | |
253 | 253 | case 'textarea' : |
254 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
254 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
255 | 255 | $fld .= $extra_desc; |
256 | 256 | break; |
257 | 257 | |
258 | 258 | case 'checkbox' : |
259 | 259 | $c_input = ''; |
260 | - if ( is_array($value) ) { |
|
261 | - foreach ( $value as $key => $val ) { |
|
262 | - $c_id = $field_name . '_' . $value; |
|
263 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
264 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
265 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
266 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
260 | + if (is_array($value)) { |
|
261 | + foreach ($value as $key => $val) { |
|
262 | + $c_id = $field_name.'_'.$value; |
|
263 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
264 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
265 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
266 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
267 | 267 | } |
268 | 268 | $fld = $c_input; |
269 | 269 | } else { |
270 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
271 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
270 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
271 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
272 | 272 | } |
273 | 273 | break; |
274 | 274 | |
275 | 275 | case 'radio' : |
276 | 276 | $c_input = ''; |
277 | - if ( is_array($value) ) { |
|
278 | - foreach ( $value as $key => $val ) { |
|
279 | - $c_id = $field_name . '_' . $value; |
|
280 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
281 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
282 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
283 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
277 | + if (is_array($value)) { |
|
278 | + foreach ($value as $key => $val) { |
|
279 | + $c_id = $field_name.'_'.$value; |
|
280 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
281 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
282 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
283 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
284 | 284 | } |
285 | 285 | $fld = $c_input; |
286 | 286 | } else { |
287 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
288 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
287 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
288 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
289 | 289 | } |
290 | 290 | break; |
291 | 291 | |
292 | 292 | case 'hidden' : |
293 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
293 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
294 | 294 | break; |
295 | 295 | |
296 | 296 | case 'select' : |
297 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
298 | - foreach ( $value as $key => $val ) { |
|
299 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
300 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
297 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
298 | + foreach ($value as $key => $val) { |
|
299 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
300 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
301 | 301 | } |
302 | 302 | $fld .= '</select>'; |
303 | 303 | break; |
@@ -309,21 +309,21 @@ discard block |
||
309 | 309 | 'editor_class' => $class, |
310 | 310 | 'tabindex' => $tabindex |
311 | 311 | ); |
312 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
312 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
313 | 313 | ob_start(); |
314 | - wp_editor( $value, $id, $editor_settings ); |
|
314 | + wp_editor($value, $id, $editor_settings); |
|
315 | 315 | $editor = ob_get_contents(); |
316 | 316 | ob_end_clean(); |
317 | 317 | $fld = $editor; |
318 | 318 | break; |
319 | 319 | |
320 | 320 | default : //'text fields' |
321 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
321 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
322 | 322 | $fld .= $extra_desc; |
323 | 323 | |
324 | 324 | } |
325 | 325 | |
326 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
326 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | return $form_fields; |
@@ -352,22 +352,22 @@ discard block |
||
352 | 352 | */ |
353 | 353 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
354 | 354 | //if $values was submitted in the wrong format, convert it over |
355 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
356 | - $converted_values=array(); |
|
357 | - foreach($values as $id=>$text){ |
|
358 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
355 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
356 | + $converted_values = array(); |
|
357 | + foreach ($values as $id=>$text) { |
|
358 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
359 | 359 | } |
360 | - $values=$converted_values; |
|
360 | + $values = $converted_values; |
|
361 | 361 | } |
362 | 362 | //load formatter helper |
363 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
363 | + EE_Registry::instance()->load_helper('Formatter'); |
|
364 | 364 | //EE_Registry::instance()->load_helper( 'Formatter' ); |
365 | 365 | |
366 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
366 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
367 | 367 | //Debug |
368 | 368 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
369 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
370 | - $field .= ' ' . $parameters; |
|
369 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
370 | + $field .= ' '.$parameters; |
|
371 | 371 | if ($autosize) { |
372 | 372 | $size = 'med'; |
373 | 373 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -380,21 +380,21 @@ discard block |
||
380 | 380 | $size = ''; |
381 | 381 | } |
382 | 382 | |
383 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
383 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
384 | 384 | |
385 | 385 | if (empty($default) && isset($GLOBALS[$name])) |
386 | 386 | $default = stripslashes($GLOBALS[$name]); |
387 | 387 | |
388 | 388 | |
389 | 389 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
390 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
390 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
391 | 391 | if ($default == $values[$i]['id']) { |
392 | 392 | $field .= ' selected = "selected"'; |
393 | 393 | } |
394 | - if ( isset( $values[$i]['class'] ) ) { |
|
395 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
394 | + if (isset($values[$i]['class'])) { |
|
395 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
396 | 396 | } |
397 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
397 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
398 | 398 | } |
399 | 399 | $field .= '</select>'; |
400 | 400 | |
@@ -412,38 +412,38 @@ discard block |
||
412 | 412 | * @param string $question_groups |
413 | 413 | * @return string HTML |
414 | 414 | */ |
415 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
415 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
416 | 416 | |
417 | 417 | $html = ''; |
418 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
419 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
418 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
419 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
420 | 420 | |
421 | - if ( ! empty( $question_groups )) { |
|
421 | + if ( ! empty($question_groups)) { |
|
422 | 422 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
423 | 423 | // loop thru question groups |
424 | - foreach ( $question_groups as $QSG ) { |
|
424 | + foreach ($question_groups as $QSG) { |
|
425 | 425 | // check that questions exist |
426 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
426 | + if ( ! empty($QSG['QSG_questions'])) { |
|
427 | 427 | // use fieldsets |
428 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
428 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
429 | 429 | // group_name |
430 | - $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer( $QSG['QSG_name'] ) . '</h5>' : ''; |
|
430 | + $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : ''; |
|
431 | 431 | // group_desc |
432 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
432 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
433 | 433 | |
434 | 434 | $html .= $before_question_group_questions; |
435 | 435 | // loop thru questions |
436 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
436 | + foreach ($QSG['QSG_questions'] as $question) { |
|
437 | 437 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
438 | 438 | $QFI = new EE_Question_Form_Input( |
439 | 439 | $question['qst_obj'], |
440 | 440 | $question['ans_obj'], |
441 | 441 | $question |
442 | 442 | ); |
443 | - $html .= self::generate_form_input( $QFI ); |
|
443 | + $html .= self::generate_form_input($QFI); |
|
444 | 444 | } |
445 | 445 | $html .= $after_question_group_questions; |
446 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
446 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | } |
@@ -463,11 +463,11 @@ discard block |
||
463 | 463 | * @param string $group_wrapper |
464 | 464 | * @return string HTML |
465 | 465 | */ |
466 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
466 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
467 | 467 | |
468 | 468 | $html = ''; |
469 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
470 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
469 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
470 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
471 | 471 | |
472 | 472 | $default_q_meta = array( |
473 | 473 | 'att_nmbr' => 1, |
@@ -476,55 +476,55 @@ discard block |
||
476 | 476 | 'input_id' => '', |
477 | 477 | 'input_class' => '' |
478 | 478 | ); |
479 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
479 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
480 | 480 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
481 | 481 | |
482 | - if ( ! empty( $question_groups )) { |
|
482 | + if ( ! empty($question_groups)) { |
|
483 | 483 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
484 | 484 | // loop thru question groups |
485 | - foreach ( $question_groups as $QSG ) { |
|
486 | - if ( $QSG instanceof EE_Question_Group ) { |
|
485 | + foreach ($question_groups as $QSG) { |
|
486 | + if ($QSG instanceof EE_Question_Group) { |
|
487 | 487 | // check that questions exist |
488 | 488 | |
489 | - $where = array( 'QST_deleted' => 0 ); |
|
490 | - if ( ! $from_admin ) { |
|
489 | + $where = array('QST_deleted' => 0); |
|
490 | + if ( ! $from_admin) { |
|
491 | 491 | $where['QST_admin_only'] = 0; |
492 | 492 | } |
493 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
494 | - if ( ! empty( $questions )) { |
|
493 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
494 | + if ( ! empty($questions)) { |
|
495 | 495 | // use fieldsets |
496 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
496 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
497 | 497 | // group_name |
498 | - if ( $QSG->show_group_name() ) { |
|
499 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
498 | + if ($QSG->show_group_name()) { |
|
499 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
500 | 500 | } |
501 | 501 | // group_desc |
502 | - if ( $QSG->show_group_desc() ) { |
|
503 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
502 | + if ($QSG->show_group_desc()) { |
|
503 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | $html .= $before_question_group_questions; |
507 | 507 | // loop thru questions |
508 | - foreach ( $questions as $QST ) { |
|
508 | + foreach ($questions as $QST) { |
|
509 | 509 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
510 | 510 | |
511 | 511 | $answer = NULL; |
512 | 512 | |
513 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
513 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
514 | 514 | // check for answer in $_GET in case we are reprocessing a form after an error |
515 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
516 | - $answer = is_array( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ); |
|
515 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
516 | + $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]); |
|
517 | 517 | } |
518 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
518 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
519 | 519 | //attendee data from the session |
520 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
520 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
524 | 524 | |
525 | 525 | $QFI = new EE_Question_Form_Input( |
526 | 526 | $QST, |
527 | - EE_Answer::new_instance ( array( |
|
527 | + EE_Answer::new_instance(array( |
|
528 | 528 | 'ANS_ID'=> 0, |
529 | 529 | 'QST_ID'=> 0, |
530 | 530 | 'REG_ID'=> 0, |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | $q_meta |
534 | 534 | ); |
535 | 535 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
536 | - $html .= self::generate_form_input( $QFI ); |
|
536 | + $html .= self::generate_form_input($QFI); |
|
537 | 537 | } |
538 | 538 | $html .= $after_question_group_questions; |
539 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
539 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | } |
@@ -556,63 +556,63 @@ discard block |
||
556 | 556 | * @param EE_Question_Form_Input $QFI |
557 | 557 | * @return string HTML |
558 | 558 | */ |
559 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
560 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
559 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
560 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
561 | 561 | return ''; |
562 | 562 | } |
563 | 563 | |
564 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
565 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
564 | + $QFI = self::_load_system_dropdowns($QFI); |
|
565 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
566 | 566 | |
567 | 567 | //we also need to verify |
568 | 568 | |
569 | 569 | $display_text = $QFI->get('QST_display_text'); |
570 | 570 | $input_name = $QFI->get('QST_input_name'); |
571 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
571 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
572 | 572 | $input_id = $QFI->get('QST_input_id'); |
573 | 573 | $input_class = $QFI->get('QST_input_class'); |
574 | 574 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
575 | 575 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
576 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
576 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
577 | 577 | $QST_required = $QFI->get('QST_required'); |
578 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
579 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
580 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
581 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
578 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
579 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
580 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
581 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
582 | 582 | $label_class = 'espresso-form-input-lbl'; |
583 | - $QST_options = $QFI->options(true,$answer); |
|
584 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
583 | + $QST_options = $QFI->options(true, $answer); |
|
584 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
585 | 585 | $system_ID = $QFI->get('QST_system'); |
586 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
587 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
586 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
587 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
588 | 588 | |
589 | 589 | |
590 | - switch ( $QFI->get('QST_type') ){ |
|
590 | + switch ($QFI->get('QST_type')) { |
|
591 | 591 | |
592 | 592 | case 'TEXTAREA' : |
593 | - return EEH_Form_Fields::textarea( $display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
593 | + return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
594 | 594 | break; |
595 | 595 | |
596 | 596 | case 'DROPDOWN' : |
597 | - return EEH_Form_Fields::select( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE ); |
|
597 | + return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE); |
|
598 | 598 | break; |
599 | 599 | |
600 | 600 | |
601 | 601 | case 'RADIO_BTN' : |
602 | - return EEH_Form_Fields::radio( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label ); |
|
602 | + return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label); |
|
603 | 603 | break; |
604 | 604 | |
605 | 605 | case 'CHECKBOX' : |
606 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
606 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
607 | 607 | break; |
608 | 608 | |
609 | 609 | case 'DATE' : |
610 | - return EEH_Form_Fields::datepicker( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
610 | + return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'TEXT' : |
614 | 614 | default: |
615 | - return EEH_Form_Fields::text( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
615 | + return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
616 | 616 | break; |
617 | 617 | |
618 | 618 | } |
@@ -638,31 +638,31 @@ discard block |
||
638 | 638 | * @param string $disabled disabled="disabled" or null |
639 | 639 | * @return string HTML |
640 | 640 | */ |
641 | - static function text( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
641 | + static function text($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
642 | 642 | // need these |
643 | - if ( ! $question || ! $name ) { |
|
643 | + if ( ! $question || ! $name) { |
|
644 | 644 | return NULL; |
645 | 645 | } |
646 | 646 | // prep the answer |
647 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
647 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
648 | 648 | // prep the required array |
649 | - $required = self::prep_required( $required ); |
|
649 | + $required = self::prep_required($required); |
|
650 | 650 | // set disabled tag |
651 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
651 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
652 | 652 | // ya gots ta have style man!!! |
653 | 653 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
654 | - $class = empty( $class ) ? $txt_class : $class; |
|
655 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
656 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
654 | + $class = empty($class) ? $txt_class : $class; |
|
655 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
656 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
657 | 657 | |
658 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
658 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
659 | 659 | // filter label but ensure required text comes before it |
660 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
660 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
661 | 661 | |
662 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
662 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
663 | 663 | |
664 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
665 | - return $label_html . $input_html; |
|
664 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
665 | + return $label_html.$input_html; |
|
666 | 666 | |
667 | 667 | } |
668 | 668 | |
@@ -684,35 +684,35 @@ discard block |
||
684 | 684 | * @param string $disabled disabled="disabled" or null |
685 | 685 | * @return string HTML |
686 | 686 | */ |
687 | - static function textarea( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
687 | + static function textarea($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
688 | 688 | // need these |
689 | - if ( ! $question || ! $name ) { |
|
689 | + if ( ! $question || ! $name) { |
|
690 | 690 | return NULL; |
691 | 691 | } |
692 | 692 | // prep the answer |
693 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
693 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
694 | 694 | // prep the required array |
695 | - $required = self::prep_required( $required ); |
|
695 | + $required = self::prep_required($required); |
|
696 | 696 | // make sure $dimensions is an array |
697 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
697 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
698 | 698 | // and set some defaults |
699 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
699 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
700 | 700 | // set disabled tag |
701 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
701 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
702 | 702 | // ya gots ta have style man!!! |
703 | 703 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
704 | - $class = empty( $class ) ? $txt_class : $class; |
|
705 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
706 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
704 | + $class = empty($class) ? $txt_class : $class; |
|
705 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
706 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
707 | 707 | |
708 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
708 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
709 | 709 | // filter label but ensure required text comes before it |
710 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
710 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
711 | 711 | |
712 | - $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '" title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>'; |
|
712 | + $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'" title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>'; |
|
713 | 713 | |
714 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
715 | - return $label_html . $input_html; |
|
714 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
715 | + return $label_html.$input_html; |
|
716 | 716 | |
717 | 717 | } |
718 | 718 | |
@@ -735,47 +735,47 @@ discard block |
||
735 | 735 | * @param string $disabled disabled="disabled" or null |
736 | 736 | * @return string HTML |
737 | 737 | */ |
738 | - static function select( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE ) { |
|
738 | + static function select($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE) { |
|
739 | 739 | |
740 | 740 | // need these |
741 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
741 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
742 | 742 | return NULL; |
743 | 743 | } |
744 | 744 | // prep the answer |
745 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer )) : self::prep_answer( $answer, $use_html_entities ); |
|
745 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer)) : self::prep_answer($answer, $use_html_entities); |
|
746 | 746 | // prep the required array |
747 | - $required = self::prep_required( $required ); |
|
747 | + $required = self::prep_required($required); |
|
748 | 748 | // set disabled tag |
749 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
749 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
750 | 750 | // ya gots ta have style man!!! |
751 | 751 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
752 | - $class = empty( $class ) ? $txt_class : $class; |
|
753 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
754 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
752 | + $class = empty($class) ? $txt_class : $class; |
|
753 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
754 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
755 | 755 | |
756 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
756 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
757 | 757 | // filter label but ensure required text comes before it |
758 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
758 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
759 | 759 | |
760 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
760 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
761 | 761 | // recursively count array elements, to determine total number of options |
762 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
763 | - if ( ! $only_option ) { |
|
762 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
763 | + if ( ! $only_option) { |
|
764 | 764 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
765 | 765 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
766 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
766 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
767 | 767 | } |
768 | - foreach ( $options as $key => $value ) { |
|
768 | + foreach ($options as $key => $value) { |
|
769 | 769 | // if value is an array, then create option groups, else create regular ol' options |
770 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option ); |
|
770 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option); |
|
771 | 771 | } |
772 | 772 | |
773 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
773 | + $input_html .= "\n\t\t\t".'</select>'; |
|
774 | 774 | |
775 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
775 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
776 | 776 | |
777 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
778 | - return $label_html . $input_html; |
|
777 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
778 | + return $label_html.$input_html; |
|
779 | 779 | |
780 | 780 | } |
781 | 781 | |
@@ -792,12 +792,12 @@ discard block |
||
792 | 792 | * @param mixed $answer |
793 | 793 | * @return string |
794 | 794 | */ |
795 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer ){ |
|
796 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
797 | - foreach ( $QSOs as $QSO ) { |
|
798 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer ); |
|
795 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer) { |
|
796 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
797 | + foreach ($QSOs as $QSO) { |
|
798 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer); |
|
799 | 799 | } |
800 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
800 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
801 | 801 | return $html; |
802 | 802 | } |
803 | 803 | |
@@ -811,12 +811,12 @@ discard block |
||
811 | 811 | * @param int $only_option |
812 | 812 | * @return string |
813 | 813 | */ |
814 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE ){ |
|
815 | - $key = self::prep_answer( $key ); |
|
816 | - $value = self::prep_answer( $value ); |
|
817 | - $value = ! empty( $value ) ? $value : $key; |
|
818 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
819 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
814 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE) { |
|
815 | + $key = self::prep_answer($key); |
|
816 | + $value = self::prep_answer($value); |
|
817 | + $value = ! empty($value) ? $value : $key; |
|
818 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
819 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | |
@@ -840,56 +840,56 @@ discard block |
||
840 | 840 | * @param bool $use_desc_4_label |
841 | 841 | * @return string HTML |
842 | 842 | */ |
843 | - static function radio( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE ) { |
|
843 | + static function radio($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE) { |
|
844 | 844 | // need these |
845 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
845 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
846 | 846 | return NULL; |
847 | 847 | } |
848 | 848 | // prep the answer |
849 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
849 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
850 | 850 | // prep the required array |
851 | - $required = self::prep_required( $required ); |
|
851 | + $required = self::prep_required($required); |
|
852 | 852 | // set disabled tag |
853 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
853 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
854 | 854 | // ya gots ta have style man!!! |
855 | 855 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
856 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
857 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
856 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
857 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
858 | 858 | |
859 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
859 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
860 | 860 | // filter label but ensure required text comes before it |
861 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
861 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
862 | 862 | |
863 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
863 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
864 | 864 | |
865 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
866 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
865 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
866 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
867 | 867 | |
868 | - foreach ( $options as $OPT ) { |
|
869 | - if ( $OPT instanceof EE_Question_Option ) { |
|
870 | - $value = self::prep_option_value( $OPT->value() ); |
|
868 | + foreach ($options as $OPT) { |
|
869 | + if ($OPT instanceof EE_Question_Option) { |
|
870 | + $value = self::prep_option_value($OPT->value()); |
|
871 | 871 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
872 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
873 | - $desc = $OPT->desc();//no self::prep_answer |
|
874 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
875 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
876 | - $opt = '-' . sanitize_key( $value ); |
|
877 | - |
|
878 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
879 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
880 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
881 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
882 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
883 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
884 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
885 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
872 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
873 | + $desc = $OPT->desc(); //no self::prep_answer |
|
874 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
875 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
876 | + $opt = '-'.sanitize_key($value); |
|
877 | + |
|
878 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
879 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
880 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
881 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
882 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
883 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
884 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
885 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
886 | 886 | } |
887 | 887 | } |
888 | 888 | |
889 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
889 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
890 | 890 | |
891 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
892 | - return $label_html . $input_html; |
|
891 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
892 | + return $label_html.$input_html; |
|
893 | 893 | |
894 | 894 | } |
895 | 895 | |
@@ -912,65 +912,65 @@ discard block |
||
912 | 912 | * @param string $disabled disabled="disabled" or null |
913 | 913 | * @return string HTML |
914 | 914 | */ |
915 | - static function checkbox( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
915 | + static function checkbox($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
916 | 916 | // need these |
917 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
917 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
918 | 918 | return NULL; |
919 | 919 | } |
920 | - $answer = maybe_unserialize( $answer ); |
|
920 | + $answer = maybe_unserialize($answer); |
|
921 | 921 | |
922 | 922 | // prep the answer(s) |
923 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
923 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
924 | 924 | |
925 | - foreach ( $answer as $key => $value ) { |
|
926 | - $key = self::prep_option_value( $key ); |
|
927 | - $answer[$key] = self::prep_answer( $value ); |
|
925 | + foreach ($answer as $key => $value) { |
|
926 | + $key = self::prep_option_value($key); |
|
927 | + $answer[$key] = self::prep_answer($value); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | // prep the required array |
931 | - $required = self::prep_required( $required ); |
|
931 | + $required = self::prep_required($required); |
|
932 | 932 | // set disabled tag |
933 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
933 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
934 | 934 | // ya gots ta have style man!!! |
935 | 935 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
936 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
937 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
936 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
937 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
938 | 938 | |
939 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
939 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
940 | 940 | // filter label but ensure required text comes before it |
941 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
942 | - |
|
943 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
944 | - |
|
945 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
946 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
947 | - |
|
948 | - foreach ( $options as $OPT ) { |
|
949 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
950 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
951 | - $text = self::prep_answer( $OPT->value() ); |
|
952 | - $desc = $OPT->desc() ; |
|
953 | - $opt = '-' . sanitize_key( $value ); |
|
954 | - |
|
955 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
956 | - |
|
957 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
958 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
959 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
960 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
961 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
962 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
963 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
964 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
941 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
942 | + |
|
943 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
944 | + |
|
945 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
946 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
947 | + |
|
948 | + foreach ($options as $OPT) { |
|
949 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
950 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
951 | + $text = self::prep_answer($OPT->value()); |
|
952 | + $desc = $OPT->desc(); |
|
953 | + $opt = '-'.sanitize_key($value); |
|
954 | + |
|
955 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
956 | + |
|
957 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
958 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
959 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
960 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
961 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
962 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
963 | + if ( ! empty($desc) && $desc != $text) { |
|
964 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
965 | 965 | } |
966 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
966 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
967 | 967 | |
968 | 968 | } |
969 | 969 | |
970 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
970 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
971 | 971 | |
972 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
973 | - return $label_html . $input_html; |
|
972 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
973 | + return $label_html.$input_html; |
|
974 | 974 | |
975 | 975 | } |
976 | 976 | |
@@ -992,36 +992,36 @@ discard block |
||
992 | 992 | * @param string $disabled disabled="disabled" or null |
993 | 993 | * @return string HTML |
994 | 994 | */ |
995 | - static function datepicker( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
995 | + static function datepicker($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
996 | 996 | // need these |
997 | - if ( ! $question || ! $name ) { |
|
997 | + if ( ! $question || ! $name) { |
|
998 | 998 | return NULL; |
999 | 999 | } |
1000 | 1000 | // prep the answer |
1001 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1001 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1002 | 1002 | // prep the required array |
1003 | - $required = self::prep_required( $required ); |
|
1003 | + $required = self::prep_required($required); |
|
1004 | 1004 | // set disabled tag |
1005 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1005 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1006 | 1006 | // ya gots ta have style man!!! |
1007 | 1007 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1008 | - $class = empty( $class ) ? $txt_class : $class; |
|
1009 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1010 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1008 | + $class = empty($class) ? $txt_class : $class; |
|
1009 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1010 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1011 | 1011 | |
1012 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1012 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1013 | 1013 | // filter label but ensure required text comes before it |
1014 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1014 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1015 | 1015 | |
1016 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . ' ' . $extra . '/>'; |
|
1016 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
1017 | 1017 | |
1018 | 1018 | // enqueue scripts |
1019 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1020 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1021 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1019 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1020 | + wp_enqueue_style('espresso-ui-theme'); |
|
1021 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1022 | 1022 | |
1023 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1024 | - return $label_html . $input_html; |
|
1023 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1024 | + return $label_html.$input_html; |
|
1025 | 1025 | |
1026 | 1026 | } |
1027 | 1027 | |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | * @access public |
1034 | 1034 | * @return string |
1035 | 1035 | */ |
1036 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1036 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1037 | 1037 | return $required_text; |
1038 | 1038 | } |
1039 | 1039 | |
@@ -1047,9 +1047,9 @@ discard block |
||
1047 | 1047 | * @param string $value |
1048 | 1048 | * @return string HTML |
1049 | 1049 | */ |
1050 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1051 | - $id = ! empty( $id ) ? $id : $name; |
|
1052 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1050 | + static function hidden_input($name, $value, $id = '') { |
|
1051 | + $id = ! empty($id) ? $id : $name; |
|
1052 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | * @param string $question |
1062 | 1062 | * @return string |
1063 | 1063 | */ |
1064 | - static function prep_question( $question ){ |
|
1064 | + static function prep_question($question) { |
|
1065 | 1065 | return $question; |
1066 | 1066 | // $link = ''; |
1067 | 1067 | // // does this label have a help link attached ? |
@@ -1084,13 +1084,13 @@ discard block |
||
1084 | 1084 | * @param mixed $answer |
1085 | 1085 | * @return string |
1086 | 1086 | */ |
1087 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1087 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1088 | 1088 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1089 | - if ( is_bool( $answer ) ) { |
|
1089 | + if (is_bool($answer)) { |
|
1090 | 1090 | $answer = $answer ? 1 : 0; |
1091 | 1091 | } |
1092 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1093 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1092 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1093 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | |
@@ -1100,18 +1100,18 @@ discard block |
||
1100 | 1100 | * @param array $QSOs array of EE_Question_Option objects |
1101 | 1101 | * @return array |
1102 | 1102 | */ |
1103 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1103 | + public static function prep_answer_options($QSOs = array()) { |
|
1104 | 1104 | $prepped_answer_options = array(); |
1105 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1106 | - foreach( $QSOs as $key => $QSO ) { |
|
1107 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1108 | - $QSO = EE_Question_Option::new_instance( array( |
|
1109 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1110 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1105 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1106 | + foreach ($QSOs as $key => $QSO) { |
|
1107 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1108 | + $QSO = EE_Question_Option::new_instance(array( |
|
1109 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1110 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1111 | 1111 | )); |
1112 | 1112 | } |
1113 | - if ( $QSO->opt_group() ) { |
|
1114 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1113 | + if ($QSO->opt_group()) { |
|
1114 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1115 | 1115 | } else { |
1116 | 1116 | $prepped_answer_options[] = $QSO; |
1117 | 1117 | } |
@@ -1127,8 +1127,8 @@ discard block |
||
1127 | 1127 | * @param string $option_value |
1128 | 1128 | * @return string |
1129 | 1129 | */ |
1130 | - static function prep_option_value( $option_value ){ |
|
1131 | - return trim( stripslashes( $option_value )); |
|
1130 | + static function prep_option_value($option_value) { |
|
1131 | + return trim(stripslashes($option_value)); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | |
@@ -1139,11 +1139,11 @@ discard block |
||
1139 | 1139 | * @param string|array $required |
1140 | 1140 | * @return array |
1141 | 1141 | */ |
1142 | - static function prep_required( $required = array() ){ |
|
1142 | + static function prep_required($required = array()) { |
|
1143 | 1143 | // make sure required is an array |
1144 | - $required = is_array( $required ) ? $required : array(); |
|
1144 | + $required = is_array($required) ? $required : array(); |
|
1145 | 1145 | // and set some defaults |
1146 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1146 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1147 | 1147 | return $required; |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1154,30 +1154,30 @@ discard block |
||
1154 | 1154 | * @param string $value |
1155 | 1155 | * @return string |
1156 | 1156 | */ |
1157 | - static function get_label_size_class( $value = FALSE ){ |
|
1158 | - if ( $value === FALSE || $value == '' ) { |
|
1157 | + static function get_label_size_class($value = FALSE) { |
|
1158 | + if ($value === FALSE || $value == '') { |
|
1159 | 1159 | return ' class="medium-lbl"'; |
1160 | 1160 | } |
1161 | 1161 | // determine length of option value |
1162 | - $val_size = strlen( $value ); |
|
1163 | - switch( $val_size ){ |
|
1162 | + $val_size = strlen($value); |
|
1163 | + switch ($val_size) { |
|
1164 | 1164 | case $val_size < 3 : |
1165 | - $size = ' class="nano-lbl"'; |
|
1165 | + $size = ' class="nano-lbl"'; |
|
1166 | 1166 | break; |
1167 | 1167 | case $val_size < 6 : |
1168 | - $size = ' class="micro-lbl"'; |
|
1168 | + $size = ' class="micro-lbl"'; |
|
1169 | 1169 | break; |
1170 | 1170 | case $val_size < 12 : |
1171 | - $size = ' class="tiny-lbl"'; |
|
1171 | + $size = ' class="tiny-lbl"'; |
|
1172 | 1172 | break; |
1173 | 1173 | case $val_size < 25 : |
1174 | - $size = ' class="small-lbl"'; |
|
1174 | + $size = ' class="small-lbl"'; |
|
1175 | 1175 | break; |
1176 | 1176 | case $val_size > 100 : |
1177 | - $size = ' class="big-lbl"'; |
|
1177 | + $size = ' class="big-lbl"'; |
|
1178 | 1178 | break; |
1179 | 1179 | default: |
1180 | - $size = ' class="medium-lbl"'; |
|
1180 | + $size = ' class="medium-lbl"'; |
|
1181 | 1181 | break; |
1182 | 1182 | } |
1183 | 1183 | return $size; |
@@ -1191,20 +1191,20 @@ discard block |
||
1191 | 1191 | * @param array $QFI |
1192 | 1192 | * @return array |
1193 | 1193 | */ |
1194 | - private static function _load_system_dropdowns( $QFI ){ |
|
1194 | + private static function _load_system_dropdowns($QFI) { |
|
1195 | 1195 | $QST_system = $QFI->get('QST_system'); |
1196 | - switch ( $QST_system ) { |
|
1196 | + switch ($QST_system) { |
|
1197 | 1197 | case 'state' : |
1198 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1198 | + $QFI = self::generate_state_dropdown($QFI); |
|
1199 | 1199 | break; |
1200 | 1200 | case 'country' : |
1201 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1201 | + $QFI = self::generate_country_dropdown($QFI); |
|
1202 | 1202 | break; |
1203 | 1203 | case 'admin-state' : |
1204 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1204 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1205 | 1205 | break; |
1206 | 1206 | case 'admin-country' : |
1207 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1207 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1208 | 1208 | break; |
1209 | 1209 | } |
1210 | 1210 | return $QFI; |
@@ -1221,13 +1221,13 @@ discard block |
||
1221 | 1221 | * |
1222 | 1222 | * @return EE_Question_Form_Input |
1223 | 1223 | */ |
1224 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1225 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1224 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1225 | + switch ($QFI->get('QST_type')) { |
|
1226 | 1226 | case 'STATE' : |
1227 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1227 | + $QFI = self::generate_state_dropdown($QFI); |
|
1228 | 1228 | break; |
1229 | 1229 | case 'COUNTRY' : |
1230 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1230 | + $QFI = self::generate_country_dropdown($QFI); |
|
1231 | 1231 | break; |
1232 | 1232 | } |
1233 | 1233 | return $QFI; |
@@ -1241,23 +1241,23 @@ discard block |
||
1241 | 1241 | * @param bool $get_all |
1242 | 1242 | * @return array |
1243 | 1243 | */ |
1244 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1244 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1245 | 1245 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1246 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1247 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1246 | + if ($states && count($states) != count($QST->options())) { |
|
1247 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1248 | 1248 | // if multiple countries, we'll create option groups within the dropdown |
1249 | - foreach ( $states as $state ) { |
|
1250 | - if ( $state instanceof EE_State ) { |
|
1251 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1249 | + foreach ($states as $state) { |
|
1250 | + if ($state instanceof EE_State) { |
|
1251 | + $QSO = EE_Question_Option::new_instance(array( |
|
1252 | 1252 | 'QSO_value' => $state->ID(), |
1253 | 1253 | 'QSO_desc' => $state->name(), |
1254 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1254 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1255 | 1255 | 'QSO_deleted' => FALSE |
1256 | 1256 | )); |
1257 | 1257 | // set option group |
1258 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1258 | + $QSO->set_opt_group($state->country()->name()); |
|
1259 | 1259 | // add option to question |
1260 | - $QST->add_temp_option( $QSO ); |
|
1260 | + $QST->add_temp_option($QSO); |
|
1261 | 1261 | } |
1262 | 1262 | } |
1263 | 1263 | } |
@@ -1273,20 +1273,20 @@ discard block |
||
1273 | 1273 | * @internal param array $question |
1274 | 1274 | * @return array |
1275 | 1275 | */ |
1276 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1276 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1277 | 1277 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1278 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1279 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1278 | + if ($countries && count($countries) != count($QST->options())) { |
|
1279 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1280 | 1280 | // now add countries |
1281 | - foreach ( $countries as $country ) { |
|
1282 | - if ( $country instanceof EE_Country ) { |
|
1283 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1281 | + foreach ($countries as $country) { |
|
1282 | + if ($country instanceof EE_Country) { |
|
1283 | + $QSO = EE_Question_Option::new_instance(array( |
|
1284 | 1284 | 'QSO_value' => $country->ID(), |
1285 | 1285 | 'QSO_desc' => $country->name(), |
1286 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1286 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1287 | 1287 | 'QSO_deleted' => FALSE |
1288 | 1288 | )); |
1289 | - $QST->add_temp_option( $QSO ); |
|
1289 | + $QST->add_temp_option($QSO); |
|
1290 | 1290 | } |
1291 | 1291 | } |
1292 | 1292 | } |
@@ -1303,11 +1303,11 @@ discard block |
||
1303 | 1303 | */ |
1304 | 1304 | public static function two_digit_months_dropdown_options() { |
1305 | 1305 | $options = array(); |
1306 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1307 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1308 | - $options[ (string)$mm ] = (string)$mm; |
|
1306 | + for ($x = 1; $x <= 12; $x++) { |
|
1307 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1308 | + $options[(string) $mm] = (string) $mm; |
|
1309 | 1309 | } |
1310 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1310 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1311 | 1311 | } |
1312 | 1312 | |
1313 | 1313 | |
@@ -1322,11 +1322,11 @@ discard block |
||
1322 | 1322 | $options = array(); |
1323 | 1323 | $current_year = date('y'); |
1324 | 1324 | $next_decade = $current_year + 10; |
1325 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1326 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1327 | - $options[ (string)$yy ] = (string)$yy; |
|
1325 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1326 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1327 | + $options[(string) $yy] = (string) $yy; |
|
1328 | 1328 | } |
1329 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1329 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | |
@@ -1340,17 +1340,17 @@ discard block |
||
1340 | 1340 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1341 | 1341 | * @return string html |
1342 | 1342 | */ |
1343 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1343 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1344 | 1344 | $_where = array(); |
1345 | - if ( !empty( $status ) ) { |
|
1345 | + if ( ! empty($status)) { |
|
1346 | 1346 | $_where['STS_ID'] = $status; |
1347 | 1347 | } |
1348 | 1348 | |
1349 | - if ( $evt_category > 0 ) { |
|
1349 | + if ($evt_category > 0) { |
|
1350 | 1350 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1351 | 1351 | } |
1352 | 1352 | |
1353 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1353 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1354 | 1354 | |
1355 | 1355 | //setup vals for select input helper |
1356 | 1356 | $options = array( |
@@ -1360,15 +1360,15 @@ discard block |
||
1360 | 1360 | ) |
1361 | 1361 | ); |
1362 | 1362 | |
1363 | - foreach ( $regdtts as $regdtt ) { |
|
1364 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1363 | + foreach ($regdtts as $regdtt) { |
|
1364 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1365 | 1365 | $options[] = array( |
1366 | 1366 | 'text' => $date, |
1367 | 1367 | 'id' => $date |
1368 | 1368 | ); |
1369 | 1369 | } |
1370 | 1370 | |
1371 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1371 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1372 | 1372 | } |
1373 | 1373 | |
1374 | 1374 | |
@@ -1382,18 +1382,18 @@ discard block |
||
1382 | 1382 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1383 | 1383 | * @return string html |
1384 | 1384 | */ |
1385 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1385 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1386 | 1386 | //determine what post_status our condition will have for the query. |
1387 | - switch ( $status ) { |
|
1387 | + switch ($status) { |
|
1388 | 1388 | case 'month' : |
1389 | 1389 | case 'today' : |
1390 | 1390 | case NULL : |
1391 | 1391 | case 'all' : |
1392 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1392 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1393 | 1393 | break; |
1394 | 1394 | |
1395 | 1395 | case 'draft' : |
1396 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1396 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1397 | 1397 | |
1398 | 1398 | default : |
1399 | 1399 | $where['Event.status'] = $status; |
@@ -1402,7 +1402,7 @@ discard block |
||
1402 | 1402 | //categories? |
1403 | 1403 | |
1404 | 1404 | |
1405 | - if ( !empty ( $evt_category ) ) { |
|
1405 | + if ( ! empty ($evt_category)) { |
|
1406 | 1406 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1407 | 1407 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1408 | 1408 | } |
@@ -1410,7 +1410,7 @@ discard block |
||
1410 | 1410 | |
1411 | 1411 | // $where['DTT_is_primary'] = 1; |
1412 | 1412 | |
1413 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1413 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1414 | 1414 | |
1415 | 1415 | //let's setup vals for select input helper |
1416 | 1416 | $options = array( |
@@ -1423,9 +1423,9 @@ discard block |
||
1423 | 1423 | //translate month and date |
1424 | 1424 | global $wp_locale; |
1425 | 1425 | |
1426 | - foreach ( $DTTS as $DTT ) { |
|
1427 | - $localized_date = $wp_locale->get_month( date('m', strtotime($DTT->dtt_month)) ) . ' ' . $DTT->dtt_year; |
|
1428 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1426 | + foreach ($DTTS as $DTT) { |
|
1427 | + $localized_date = $wp_locale->get_month(date('m', strtotime($DTT->dtt_month))).' '.$DTT->dtt_year; |
|
1428 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1429 | 1429 | $options[] = array( |
1430 | 1430 | 'text' => $localized_date, |
1431 | 1431 | 'id' => $id |
@@ -1433,7 +1433,7 @@ discard block |
||
1433 | 1433 | } |
1434 | 1434 | |
1435 | 1435 | |
1436 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1436 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | |
@@ -1444,7 +1444,7 @@ discard block |
||
1444 | 1444 | * @param integer $current_cat currently selected category |
1445 | 1445 | * @return string html for dropdown |
1446 | 1446 | */ |
1447 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1447 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1448 | 1448 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1449 | 1449 | $options = array( |
1450 | 1450 | '0' => array( |
@@ -1454,14 +1454,14 @@ discard block |
||
1454 | 1454 | ); |
1455 | 1455 | |
1456 | 1456 | //setup categories for dropdown |
1457 | - foreach ( $categories as $category ) { |
|
1457 | + foreach ($categories as $category) { |
|
1458 | 1458 | $options[] = array( |
1459 | 1459 | 'text' => $category->get('name'), |
1460 | 1460 | 'id' => $category->ID() |
1461 | 1461 | ); |
1462 | 1462 | } |
1463 | 1463 | |
1464 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1464 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | |
@@ -1480,20 +1480,20 @@ discard block |
||
1480 | 1480 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1481 | 1481 | * @return void |
1482 | 1482 | */ |
1483 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1483 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1484 | 1484 | $btn = ''; |
1485 | - if ( empty( $url ) || empty( $ID )) { |
|
1485 | + if (empty($url) || empty($ID)) { |
|
1486 | 1486 | return $btn; |
1487 | 1487 | } |
1488 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1489 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1490 | - if ( ! $input_only ) { |
|
1491 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1492 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1488 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1489 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1490 | + if ( ! $input_only) { |
|
1491 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1492 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1493 | 1493 | $btn_frm .= $btn; |
1494 | 1494 | $btn_frm .= '</form>'; |
1495 | 1495 | $btn = $btn_frm; |
1496 | - unset ( $btn_frm ); |
|
1496 | + unset ($btn_frm); |
|
1497 | 1497 | } |
1498 | 1498 | return $btn; |
1499 | 1499 | } |
@@ -366,14 +366,16 @@ discard block |
||
366 | 366 | $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
367 | 367 | //Debug |
368 | 368 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
369 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
370 | - $field .= ' ' . $parameters; |
|
369 | + if ( EEH_Formatter::ee_tep_not_null($parameters)) { |
|
370 | + $field .= ' ' . $parameters; |
|
371 | + } |
|
371 | 372 | if ($autosize) { |
372 | 373 | $size = 'med'; |
373 | 374 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
374 | 375 | if ($values[$ii]['text']) { |
375 | - if (strlen($values[$ii]['text']) > 5) |
|
376 | - $size = 'wide'; |
|
376 | + if (strlen($values[$ii]['text']) > 5) { |
|
377 | + $size = 'wide'; |
|
378 | + } |
|
377 | 379 | } |
378 | 380 | } |
379 | 381 | } else { |
@@ -382,8 +384,9 @@ discard block |
||
382 | 384 | |
383 | 385 | $field .= ' class="' . $class . ' ' . $size . '">'; |
384 | 386 | |
385 | - if (empty($default) && isset($GLOBALS[$name])) |
|
386 | - $default = stripslashes($GLOBALS[$name]); |
|
387 | + if (empty($default) && isset($GLOBALS[$name])) { |
|
388 | + $default = stripslashes($GLOBALS[$name]); |
|
389 | + } |
|
387 | 390 | |
388 | 391 | |
389 | 392 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | * Ensures that taxes have been applied to the order, if not applies them. |
575 | 575 | * Returns the total amount of tax |
576 | 576 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
577 | - * @return float |
|
577 | + * @return boolean |
|
578 | 578 | */ |
579 | 579 | public static function ensure_taxes_applied( $total_line_item ){ |
580 | 580 | $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * Deletes ALL children of the passed line item |
591 | 591 | * |
592 | 592 | * @param EE_Line_Item $parent_line_item |
593 | - * @return bool |
|
593 | + * @return integer |
|
594 | 594 | */ |
595 | 595 | public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
596 | 596 | $deleted = 0; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * You should call EE_Registration_Processor::calculate_reg_final_prices_per_line_item() |
621 | 621 | * after using this, to keep the registration final prices in-sync with the transaction's total. |
622 | 622 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
623 | - * @param array|bool|string $line_item_codes |
|
623 | + * @param boolean $line_item_codes |
|
624 | 624 | * @return int number of items successfully removed |
625 | 625 | */ |
626 | 626 | public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
@@ -784,6 +784,7 @@ discard block |
||
784 | 784 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
785 | 785 | * @param string $line_item_type one of the EEM_Line_Item constants |
786 | 786 | * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching |
787 | + * @param string $obj_type |
|
787 | 788 | * @return EE_Line_Item[] |
788 | 789 | */ |
789 | 790 | protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) { |
@@ -809,7 +810,7 @@ discard block |
||
809 | 810 | * @uses EEH_Line_Item::_get_descendants_by_type_and_object_type() |
810 | 811 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
811 | 812 | * @param string $OBJ_type object type (like Event) |
812 | - * @param array $OBJ_IDs array of OBJ_IDs |
|
813 | + * @param boolean[] $OBJ_IDs array of OBJ_IDs |
|
813 | 814 | * @return EE_Line_Item[] |
814 | 815 | */ |
815 | 816 | public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) { |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -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 | * EEH_Line_Item |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
41 | 41 | * @return boolean success |
42 | 42 | */ |
43 | - public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL ){ |
|
44 | - $items_subtotal = self::get_pre_tax_subtotal( $parent_line_item ); |
|
43 | + public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) { |
|
44 | + $items_subtotal = self::get_pre_tax_subtotal($parent_line_item); |
|
45 | 45 | $line_item = EE_Line_Item::new_instance(array( |
46 | 46 | 'LIN_name' => $name, |
47 | 47 | 'LIN_desc' => $description, |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | 'LIN_quantity' => $quantity, |
50 | 50 | 'LIN_percent' => null, |
51 | 51 | 'LIN_is_taxable' => $taxable, |
52 | - 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0, |
|
53 | - 'LIN_total' => floatval( $unit_price ) * intval( $quantity ), |
|
52 | + 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0, |
|
53 | + 'LIN_total' => floatval($unit_price) * intval($quantity), |
|
54 | 54 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
55 | 55 | 'LIN_code' => $code, |
56 | 56 | )); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'FHEE__EEH_Line_Item__add_unrelated_item__line_item', |
59 | 59 | $line_item |
60 | 60 | ); |
61 | - return self::add_item( $parent_line_item, $line_item ); |
|
61 | + return self::add_item($parent_line_item, $line_item); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param boolean $taxable |
80 | 80 | * @return boolean success |
81 | 81 | */ |
82 | - public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){ |
|
82 | + public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) { |
|
83 | 83 | $line_item = EE_Line_Item::new_instance(array( |
84 | 84 | 'LIN_name' => $name, |
85 | 85 | 'LIN_desc' => $description, |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | 'LIN_percent' => $percentage_amount, |
88 | 88 | 'LIN_quantity' => NULL, |
89 | 89 | 'LIN_is_taxable' => $taxable, |
90 | - 'LIN_total' => floatval( $percentage_amount * ( $parent_line_item->total() / 100 )), |
|
90 | + 'LIN_total' => floatval($percentage_amount * ($parent_line_item->total() / 100)), |
|
91 | 91 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
92 | 92 | 'LIN_parent' => $parent_line_item->ID() |
93 | 93 | )); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'FHEE__EEH_Line_Item__add_percentage_based_item__line_item', |
96 | 96 | $line_item |
97 | 97 | ); |
98 | - return self::add_item( $parent_line_item, $line_item ); |
|
98 | + return self::add_item($parent_line_item, $line_item); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | * @return \EE_Line_Item |
117 | 117 | * @throws \EE_Error |
118 | 118 | */ |
119 | - public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){ |
|
120 | - if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) { |
|
121 | - throw new EE_Error( sprintf( __( 'A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
119 | + public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
120 | + if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) { |
|
121 | + throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
122 | 122 | } |
123 | 123 | // either increment the qty for an existing ticket |
124 | - $line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty ); |
|
124 | + $line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty); |
|
125 | 125 | // or add a new one |
126 | - if ( ! $line_item instanceof EE_Line_Item ) { |
|
127 | - $line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty ); |
|
126 | + if ( ! $line_item instanceof EE_Line_Item) { |
|
127 | + $line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty); |
|
128 | 128 | } |
129 | 129 | $total_line_item->recalculate_total_including_taxes(); |
130 | 130 | return $line_item; |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | * @return \EE_Line_Item |
141 | 141 | * @throws \EE_Error |
142 | 142 | */ |
143 | - public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
143 | + public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
144 | 144 | $line_item = null; |
145 | - if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) { |
|
146 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item ); |
|
147 | - foreach ( (array)$ticket_line_items as $ticket_line_item ) { |
|
148 | - if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID() ) { |
|
145 | + if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) { |
|
146 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
147 | + foreach ((array) $ticket_line_items as $ticket_line_item) { |
|
148 | + if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID()) { |
|
149 | 149 | $line_item = $ticket_line_item; |
150 | 150 | break; |
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
154 | - if ( $line_item instanceof EE_Line_Item ) { |
|
155 | - EEH_Line_Item::increment_quantity( $line_item, $qty ); |
|
154 | + if ($line_item instanceof EE_Line_Item) { |
|
155 | + EEH_Line_Item::increment_quantity($line_item, $qty); |
|
156 | 156 | return $line_item; |
157 | 157 | } |
158 | 158 | return null; |
@@ -165,15 +165,15 @@ discard block |
||
165 | 165 | * @param int $qty |
166 | 166 | * @return void |
167 | 167 | */ |
168 | - public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
169 | - if( ! $line_item->is_percent() ) { |
|
168 | + public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
169 | + if ( ! $line_item->is_percent()) { |
|
170 | 170 | $qty += $line_item->quantity(); |
171 | - $line_item->set_quantity( $qty ); |
|
172 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
171 | + $line_item->set_quantity($qty); |
|
172 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
173 | 173 | } |
174 | - foreach( $line_item->children() as $child ) { |
|
175 | - if( $child->is_sub_line_item() ) { |
|
176 | - EEH_Line_Item::update_quantity( $child, $line_item->quantity() ); |
|
174 | + foreach ($line_item->children() as $child) { |
|
175 | + if ($child->is_sub_line_item()) { |
|
176 | + EEH_Line_Item::update_quantity($child, $line_item->quantity()); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | } |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | * @param EE_Line_Item $line_item |
185 | 185 | * @param int $new_quantity |
186 | 186 | */ |
187 | - public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) { |
|
188 | - if( ! $line_item->is_percent() ) { |
|
189 | - $line_item->set_quantity( $new_quantity ); |
|
190 | - $line_item->set_total( $line_item->unit_price() * $new_quantity ); |
|
187 | + public static function update_quantity(EE_Line_Item $line_item, $new_quantity) { |
|
188 | + if ( ! $line_item->is_percent()) { |
|
189 | + $line_item->set_quantity($new_quantity); |
|
190 | + $line_item->set_total($line_item->unit_price() * $new_quantity); |
|
191 | 191 | } |
192 | - foreach( $line_item->children() as $child ) { |
|
193 | - if( $child->is_sub_line_item() ) { |
|
194 | - EEH_Line_Item::update_quantity( $child, $new_quantity ); |
|
192 | + foreach ($line_item->children() as $child) { |
|
193 | + if ($child->is_sub_line_item()) { |
|
194 | + EEH_Line_Item::update_quantity($child, $new_quantity); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | } |
@@ -206,45 +206,45 @@ discard block |
||
206 | 206 | * @return \EE_Line_Item |
207 | 207 | * @throws \EE_Error |
208 | 208 | */ |
209 | - public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
209 | + public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
210 | 210 | $datetimes = $ticket->datetimes(); |
211 | - $first_datetime = reset( $datetimes ); |
|
212 | - if( $first_datetime instanceof EE_Datetime && |
|
213 | - $first_datetime->event() instanceof EE_Event ) { |
|
211 | + $first_datetime = reset($datetimes); |
|
212 | + if ($first_datetime instanceof EE_Datetime && |
|
213 | + $first_datetime->event() instanceof EE_Event) { |
|
214 | 214 | $first_datetime_name = $first_datetime->event()->name(); |
215 | 215 | } else { |
216 | - $first_datetime_name = __( 'Event', 'event_espresso' ); |
|
216 | + $first_datetime_name = __('Event', 'event_espresso'); |
|
217 | 217 | } |
218 | - $event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name ); |
|
218 | + $event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name); |
|
219 | 219 | // get event subtotal line |
220 | - $events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket ); |
|
221 | - if ( ! $events_sub_total instanceof EE_Line_Item ) { |
|
222 | - throw new EE_Error( sprintf( __( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
220 | + $events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket); |
|
221 | + if ( ! $events_sub_total instanceof EE_Line_Item) { |
|
222 | + throw new EE_Error(sprintf(__('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
223 | 223 | } |
224 | 224 | // add $ticket to cart |
225 | - $line_item = EE_Line_Item::new_instance( array( |
|
225 | + $line_item = EE_Line_Item::new_instance(array( |
|
226 | 226 | 'LIN_name' => $ticket->name(), |
227 | - 'LIN_desc' => $ticket->description() != '' ? $ticket->description() . ' ' . $event : $event, |
|
227 | + 'LIN_desc' => $ticket->description() != '' ? $ticket->description().' '.$event : $event, |
|
228 | 228 | 'LIN_unit_price' => $ticket->price(), |
229 | 229 | 'LIN_quantity' => $qty, |
230 | 230 | 'LIN_is_taxable' => $ticket->taxable(), |
231 | - 'LIN_order' => count( $events_sub_total->children() ), |
|
231 | + 'LIN_order' => count($events_sub_total->children()), |
|
232 | 232 | 'LIN_total' => $ticket->price() * $qty, |
233 | 233 | 'LIN_type' => EEM_Line_Item::type_line_item, |
234 | 234 | 'OBJ_ID' => $ticket->ID(), |
235 | 235 | 'OBJ_type' => 'Ticket' |
236 | - ) ); |
|
236 | + )); |
|
237 | 237 | $line_item = apply_filters( |
238 | 238 | 'FHEE__EEH_Line_Item__create_ticket_line_item__line_item', |
239 | 239 | $line_item |
240 | 240 | ); |
241 | - $events_sub_total->add_child_line_item( $line_item ); |
|
241 | + $events_sub_total->add_child_line_item($line_item); |
|
242 | 242 | //now add the sub-line items |
243 | 243 | $running_total_for_ticket = 0; |
244 | - foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) { |
|
244 | + foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) { |
|
245 | 245 | $sign = $price->is_discount() ? -1 : 1; |
246 | 246 | $price_total = $price->is_percent() ? $running_total_for_ticket * $price->amount() / 100 : $price->amount() * $qty; |
247 | - $sub_line_item = EE_Line_Item::new_instance( array( |
|
247 | + $sub_line_item = EE_Line_Item::new_instance(array( |
|
248 | 248 | 'LIN_name' => $price->name(), |
249 | 249 | 'LIN_desc' => $price->desc(), |
250 | 250 | 'LIN_quantity' => $price->is_percent() ? null : $qty, |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | 'LIN_type' => EEM_Line_Item::type_sub_line_item, |
255 | 255 | 'OBJ_ID' => $price->ID(), |
256 | 256 | 'OBJ_type' => 'Price' |
257 | - ) ); |
|
257 | + )); |
|
258 | 258 | $sub_line_item = apply_filters( |
259 | 259 | 'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item', |
260 | 260 | $sub_line_item |
261 | 261 | ); |
262 | - if ( $price->is_percent() ) { |
|
263 | - $sub_line_item->set_percent( $sign * $price->amount() ); |
|
262 | + if ($price->is_percent()) { |
|
263 | + $sub_line_item->set_percent($sign * $price->amount()); |
|
264 | 264 | } else { |
265 | - $sub_line_item->set_unit_price( $sign * $price->amount() ); |
|
265 | + $sub_line_item->set_unit_price($sign * $price->amount()); |
|
266 | 266 | } |
267 | 267 | $running_total_for_ticket += $price_total; |
268 | - $line_item->add_child_line_item( $sub_line_item ); |
|
268 | + $line_item->add_child_line_item($sub_line_item); |
|
269 | 269 | } |
270 | 270 | return $line_item; |
271 | 271 | } |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | * @param EE_Line_Item $item to be added |
284 | 284 | * @return boolean |
285 | 285 | */ |
286 | - public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){ |
|
287 | - $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
|
288 | - if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
|
286 | + public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) { |
|
287 | + $pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item); |
|
288 | + if ($pre_tax_subtotal instanceof EE_Line_Item) { |
|
289 | 289 | $success = $pre_tax_subtotal->add_child_line_item($item); |
290 | - }else{ |
|
290 | + } else { |
|
291 | 291 | return FALSE; |
292 | 292 | } |
293 | 293 | $total_line_item->recalculate_total_including_taxes(); |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
302 | 302 | * @return \EE_Line_Item |
303 | 303 | */ |
304 | - public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){ |
|
305 | - $pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' ); |
|
306 | - return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal( $total_line_item ); |
|
304 | + public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) { |
|
305 | + $pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal'); |
|
306 | + return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal($total_line_item); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
314 | 314 | * @return \EE_Line_Item |
315 | 315 | */ |
316 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){ |
|
317 | - $taxes = $total_line_item->get_child_line_item( 'taxes' ); |
|
318 | - return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item ); |
|
316 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item) { |
|
317 | + $taxes = $total_line_item->get_child_line_item('taxes'); |
|
318 | + return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | |
@@ -326,12 +326,12 @@ discard block |
||
326 | 326 | * @param EE_Transaction $transaction |
327 | 327 | * @return void |
328 | 328 | */ |
329 | - public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){ |
|
330 | - if( $transaction ){ |
|
329 | + public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) { |
|
330 | + if ($transaction) { |
|
331 | 331 | /** @type EEM_Transaction $EEM_Transaction */ |
332 | - $EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
|
333 | - $transaction = $EEM_Transaction->ensure_is_ID( $transaction ); |
|
334 | - $line_item->set_TXN_ID( $transaction ); |
|
332 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
333 | + $transaction = $EEM_Transaction->ensure_is_ID($transaction); |
|
334 | + $line_item->set_TXN_ID($transaction); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | * @param EE_Transaction $transaction |
345 | 345 | * @return \EE_Line_Item of type total |
346 | 346 | */ |
347 | - public static function create_total_line_item( $transaction = NULL ){ |
|
348 | - $total_line_item = EE_Line_Item::new_instance( array( |
|
347 | + public static function create_total_line_item($transaction = NULL) { |
|
348 | + $total_line_item = EE_Line_Item::new_instance(array( |
|
349 | 349 | 'LIN_code' => 'total', |
350 | 350 | 'LIN_name' => __('Grand Total', 'event_espresso'), |
351 | 351 | 'LIN_type' => EEM_Line_Item::type_total, |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | 'FHEE__EEH_Line_Item__create_total_line_item__total_line_item', |
356 | 356 | $total_line_item |
357 | 357 | ); |
358 | - self::set_TXN_ID( $total_line_item, $transaction ); |
|
359 | - self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
360 | - self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
358 | + self::set_TXN_ID($total_line_item, $transaction); |
|
359 | + self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
360 | + self::create_taxes_subtotal($total_line_item, $transaction); |
|
361 | 361 | return $total_line_item; |
362 | 362 | } |
363 | 363 | |
@@ -369,19 +369,19 @@ discard block |
||
369 | 369 | * @param EE_Transaction $transaction |
370 | 370 | * @return EE_Line_Item |
371 | 371 | */ |
372 | - protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
373 | - $pre_tax_line_item = EE_Line_Item::new_instance( array( |
|
372 | + protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
373 | + $pre_tax_line_item = EE_Line_Item::new_instance(array( |
|
374 | 374 | 'LIN_code' => 'pre-tax-subtotal', |
375 | - 'LIN_name' => __( 'Pre-Tax Subtotal', 'event_espresso' ), |
|
375 | + 'LIN_name' => __('Pre-Tax Subtotal', 'event_espresso'), |
|
376 | 376 | 'LIN_type' => EEM_Line_Item::type_sub_total |
377 | - ) ); |
|
377 | + )); |
|
378 | 378 | $pre_tax_line_item = apply_filters( |
379 | 379 | 'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item', |
380 | 380 | $pre_tax_line_item |
381 | 381 | ); |
382 | - self::set_TXN_ID( $pre_tax_line_item, $transaction ); |
|
383 | - $total_line_item->add_child_line_item( $pre_tax_line_item ); |
|
384 | - self::create_event_subtotal( $pre_tax_line_item, $transaction ); |
|
382 | + self::set_TXN_ID($pre_tax_line_item, $transaction); |
|
383 | + $total_line_item->add_child_line_item($pre_tax_line_item); |
|
384 | + self::create_event_subtotal($pre_tax_line_item, $transaction); |
|
385 | 385 | return $pre_tax_line_item; |
386 | 386 | } |
387 | 387 | |
@@ -394,21 +394,21 @@ discard block |
||
394 | 394 | * @param EE_Transaction $transaction |
395 | 395 | * @return EE_Line_Item |
396 | 396 | */ |
397 | - protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
397 | + protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
398 | 398 | $tax_line_item = EE_Line_Item::new_instance(array( |
399 | 399 | 'LIN_code' => 'taxes', |
400 | 400 | 'LIN_name' => __('Taxes', 'event_espresso'), |
401 | 401 | 'LIN_type' => EEM_Line_Item::type_tax_sub_total, |
402 | - 'LIN_order' => 1000,//this should always come last |
|
402 | + 'LIN_order' => 1000, //this should always come last |
|
403 | 403 | )); |
404 | 404 | $tax_line_item = apply_filters( |
405 | 405 | 'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item', |
406 | 406 | $tax_line_item |
407 | 407 | ); |
408 | - self::set_TXN_ID( $tax_line_item, $transaction ); |
|
409 | - $total_line_item->add_child_line_item( $tax_line_item ); |
|
408 | + self::set_TXN_ID($tax_line_item, $transaction); |
|
409 | + $total_line_item->add_child_line_item($tax_line_item); |
|
410 | 410 | //and lastly, add the actual taxes |
411 | - self::apply_taxes( $total_line_item ); |
|
411 | + self::apply_taxes($total_line_item); |
|
412 | 412 | return $tax_line_item; |
413 | 413 | } |
414 | 414 | |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | * @param EE_Event $event |
422 | 422 | * @return EE_Line_Item |
423 | 423 | */ |
424 | - public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){ |
|
424 | + public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) { |
|
425 | 425 | $event_line_item = EE_Line_Item::new_instance(array( |
426 | - 'LIN_code' => self::get_event_code( $event ), |
|
427 | - 'LIN_name' => self::get_event_name( $event ), |
|
428 | - 'LIN_desc' => self::get_event_desc( $event ), |
|
426 | + 'LIN_code' => self::get_event_code($event), |
|
427 | + 'LIN_name' => self::get_event_name($event), |
|
428 | + 'LIN_desc' => self::get_event_desc($event), |
|
429 | 429 | 'LIN_type' => EEM_Line_Item::type_sub_total, |
430 | 430 | 'OBJ_type' => 'Event', |
431 | 431 | 'OBJ_ID' => $event instanceof EE_Event ? $event->ID() : 0 |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | 'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item', |
435 | 435 | $event_line_item |
436 | 436 | ); |
437 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
438 | - $pre_tax_line_item->add_child_line_item( $event_line_item ); |
|
437 | + self::set_TXN_ID($event_line_item, $transaction); |
|
438 | + $pre_tax_line_item->add_child_line_item($event_line_item); |
|
439 | 439 | return $event_line_item; |
440 | 440 | } |
441 | 441 | |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | * @param EE_Event $event |
445 | 445 | * @return string |
446 | 446 | */ |
447 | - public static function get_event_code( $event ) { |
|
448 | - return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' ); |
|
447 | + public static function get_event_code($event) { |
|
448 | + return 'event-'.($event instanceof EE_Event ? $event->ID() : '0'); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * @param EE_Event $event |
454 | 454 | * @return string |
455 | 455 | */ |
456 | - public static function get_event_name( $event ) { |
|
457 | - return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
456 | + public static function get_event_name($event) { |
|
457 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @param EE_Event $event |
463 | 463 | * @return string |
464 | 464 | */ |
465 | - public static function get_event_desc( $event ) { |
|
465 | + public static function get_event_desc($event) { |
|
466 | 466 | return $event instanceof EE_Event ? $event->short_description() : ''; |
467 | 467 | } |
468 | 468 | |
@@ -476,37 +476,37 @@ discard block |
||
476 | 476 | * @throws \EE_Error |
477 | 477 | * @return EE_Line_Item |
478 | 478 | */ |
479 | - public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
|
479 | + public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) { |
|
480 | 480 | $first_datetime = $ticket->first_datetime(); |
481 | - if( ! $first_datetime instanceof EE_Datetime ){ |
|
482 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) ); |
|
481 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
482 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID())); |
|
483 | 483 | } |
484 | 484 | $event = $first_datetime->event(); |
485 | - if ( ! $event instanceof EE_Event ) { |
|
486 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no event data associated with it.','event_espresso' ), $ticket->ID() ) ); |
|
485 | + if ( ! $event instanceof EE_Event) { |
|
486 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), $ticket->ID())); |
|
487 | 487 | } |
488 | 488 | $event_line_item = NULL; |
489 | 489 | $found = false; |
490 | - foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) { |
|
490 | + foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) { |
|
491 | 491 | // default event subtotal, we should only ever find this the first time this method is called |
492 | - if ( ! $event_line_item->OBJ_ID() ) { |
|
492 | + if ( ! $event_line_item->OBJ_ID()) { |
|
493 | 493 | // let's use this! but first... set the event details |
494 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
494 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
495 | 495 | $found = true; |
496 | 496 | break; |
497 | - } else if ( $event_line_item->OBJ_ID() === $event->ID() ) { |
|
497 | + } else if ($event_line_item->OBJ_ID() === $event->ID()) { |
|
498 | 498 | // found existing line item for this event in the cart, so break out of loop and use this one |
499 | 499 | $found = true; |
500 | 500 | break; |
501 | 501 | } |
502 | 502 | } |
503 | - if ( ! $found ) { |
|
503 | + if ( ! $found) { |
|
504 | 504 | //there is no event sub-total yet, so add it |
505 | - $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total ); |
|
505 | + $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total); |
|
506 | 506 | // create a new "event" subtotal below that |
507 | - $event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event ); |
|
507 | + $event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event); |
|
508 | 508 | // and set the event details |
509 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
509 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
510 | 510 | } |
511 | 511 | return $event_line_item; |
512 | 512 | } |
@@ -520,14 +520,14 @@ discard block |
||
520 | 520 | * @param EE_Transaction $transaction |
521 | 521 | * @return EE_Line_Item |
522 | 522 | */ |
523 | - public static function set_event_subtotal_details( EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL ){ |
|
524 | - if ( $event instanceof EE_Event ) { |
|
525 | - $event_line_item->set_code( self::get_event_code( $event ) ); |
|
526 | - $event_line_item->set_name( self::get_event_name( $event ) ); |
|
527 | - $event_line_item->set_desc( self::get_event_desc( $event ) ); |
|
528 | - $event_line_item->set_OBJ_ID( $event->ID() ); |
|
523 | + public static function set_event_subtotal_details(EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL) { |
|
524 | + if ($event instanceof EE_Event) { |
|
525 | + $event_line_item->set_code(self::get_event_code($event)); |
|
526 | + $event_line_item->set_name(self::get_event_name($event)); |
|
527 | + $event_line_item->set_desc(self::get_event_desc($event)); |
|
528 | + $event_line_item->set_OBJ_ID($event->ID()); |
|
529 | 529 | } |
530 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
530 | + self::set_TXN_ID($event_line_item, $transaction); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | |
@@ -538,19 +538,19 @@ discard block |
||
538 | 538 | * any old taxes are removed |
539 | 539 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
540 | 540 | */ |
541 | - public static function apply_taxes( EE_Line_Item $total_line_item ){ |
|
541 | + public static function apply_taxes(EE_Line_Item $total_line_item) { |
|
542 | 542 | /** @type EEM_Price $EEM_Price */ |
543 | - $EEM_Price = EE_Registry::instance()->load_model( 'Price' ); |
|
543 | + $EEM_Price = EE_Registry::instance()->load_model('Price'); |
|
544 | 544 | // get array of taxes via Price Model |
545 | 545 | $ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes(); |
546 | - ksort( $ordered_taxes ); |
|
547 | - $taxes_line_item = self::get_taxes_subtotal( $total_line_item ); |
|
546 | + ksort($ordered_taxes); |
|
547 | + $taxes_line_item = self::get_taxes_subtotal($total_line_item); |
|
548 | 548 | //just to be safe, remove its old tax line items |
549 | 549 | $taxes_line_item->delete_children_line_items(); |
550 | 550 | //loop thru taxes |
551 | - foreach ( $ordered_taxes as $order => $taxes ) { |
|
552 | - foreach ( $taxes as $tax ) { |
|
553 | - if ( $tax instanceof EE_Price ) { |
|
551 | + foreach ($ordered_taxes as $order => $taxes) { |
|
552 | + foreach ($taxes as $tax) { |
|
553 | + if ($tax instanceof EE_Price) { |
|
554 | 554 | $tax_line_item = EE_Line_Item::new_instance( |
555 | 555 | array( |
556 | 556 | 'LIN_name' => $tax->name(), |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | 'FHEE__EEH_Line_Item__apply_taxes__tax_line_item', |
569 | 569 | $tax_line_item |
570 | 570 | ); |
571 | - $taxes_line_item->add_child_line_item( $tax_line_item ); |
|
571 | + $taxes_line_item->add_child_line_item($tax_line_item); |
|
572 | 572 | } |
573 | 573 | } |
574 | 574 | } |
@@ -583,10 +583,10 @@ discard block |
||
583 | 583 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
584 | 584 | * @return float |
585 | 585 | */ |
586 | - public static function ensure_taxes_applied( $total_line_item ){ |
|
587 | - $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
588 | - if( ! $taxes_subtotal->children()){ |
|
589 | - self::apply_taxes( $total_line_item ); |
|
586 | + public static function ensure_taxes_applied($total_line_item) { |
|
587 | + $taxes_subtotal = self::get_taxes_subtotal($total_line_item); |
|
588 | + if ( ! $taxes_subtotal->children()) { |
|
589 | + self::apply_taxes($total_line_item); |
|
590 | 590 | } |
591 | 591 | return $taxes_subtotal->total(); |
592 | 592 | } |
@@ -599,16 +599,16 @@ discard block |
||
599 | 599 | * @param EE_Line_Item $parent_line_item |
600 | 600 | * @return bool |
601 | 601 | */ |
602 | - public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
|
602 | + public static function delete_all_child_items(EE_Line_Item $parent_line_item) { |
|
603 | 603 | $deleted = 0; |
604 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
605 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
606 | - $deleted += EEH_Line_Item::delete_all_child_items( $child_line_item ); |
|
607 | - if ( $child_line_item->ID() ) { |
|
604 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
605 | + if ($child_line_item instanceof EE_Line_Item) { |
|
606 | + $deleted += EEH_Line_Item::delete_all_child_items($child_line_item); |
|
607 | + if ($child_line_item->ID()) { |
|
608 | 608 | $child_line_item->delete(); |
609 | - unset( $child_line_item ); |
|
609 | + unset($child_line_item); |
|
610 | 610 | } else { |
611 | - $parent_line_item->delete_child_line_item( $child_line_item->code() ); |
|
611 | + $parent_line_item->delete_child_line_item($child_line_item->code()); |
|
612 | 612 | } |
613 | 613 | $deleted++; |
614 | 614 | } |
@@ -630,25 +630,25 @@ discard block |
||
630 | 630 | * @param array|bool|string $line_item_codes |
631 | 631 | * @return int number of items successfully removed |
632 | 632 | */ |
633 | - public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
|
633 | + public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) { |
|
634 | 634 | |
635 | - if( $total_line_item->type() != EEM_Line_Item::type_total ){ |
|
636 | - EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __( 'This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso' ), '4.6.18' ); |
|
635 | + if ($total_line_item->type() != EEM_Line_Item::type_total) { |
|
636 | + EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __('This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso'), '4.6.18'); |
|
637 | 637 | } |
638 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
638 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
639 | 639 | |
640 | 640 | // check if only a single line_item_id was passed |
641 | - if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) { |
|
641 | + if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) { |
|
642 | 642 | // place single line_item_id in an array to appear as multiple line_item_ids |
643 | - $line_item_codes = array ( $line_item_codes ); |
|
643 | + $line_item_codes = array($line_item_codes); |
|
644 | 644 | } |
645 | 645 | $removals = 0; |
646 | 646 | // cycle thru line_item_ids |
647 | - foreach ( $line_item_codes as $line_item_id ) { |
|
647 | + foreach ($line_item_codes as $line_item_id) { |
|
648 | 648 | $removals += $total_line_item->delete_child_line_item($line_item_id); |
649 | 649 | } |
650 | 650 | |
651 | - if ( $removals > 0 ) { |
|
651 | + if ($removals > 0) { |
|
652 | 652 | $total_line_item->recalculate_taxes_and_tax_total(); |
653 | 653 | return $removals; |
654 | 654 | } else { |
@@ -665,17 +665,17 @@ discard block |
||
665 | 665 | * @param string $description |
666 | 666 | * @return EE_Line_Item the new tax line item created |
667 | 667 | */ |
668 | - public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL ){ |
|
668 | + public static function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL) { |
|
669 | 669 | //first: remove all tax descendants |
670 | 670 | //add this as a new tax descendant |
671 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
671 | + $tax_subtotal = self::get_taxes_subtotal($total_line_item); |
|
672 | 672 | $tax_subtotal->delete_children_line_items(); |
673 | 673 | $taxable_total = $total_line_item->taxable_total(); |
674 | 674 | $new_tax_subtotal = EE_Line_Item::new_instance(array( |
675 | 675 | 'TXN_ID' => $total_line_item->TXN_ID(), |
676 | 676 | 'LIN_name' => $name ? $name : __('Tax', 'event_espresso'), |
677 | 677 | 'LIN_desc' => $description ? $description : '', |
678 | - 'LIN_percent' => $taxable_total ? ( $amount / $total_line_item->taxable_total() * 100 ) : 0, |
|
678 | + 'LIN_percent' => $taxable_total ? ($amount / $total_line_item->taxable_total() * 100) : 0, |
|
679 | 679 | 'LIN_total' => $amount, |
680 | 680 | 'LIN_parent' => $tax_subtotal->ID(), |
681 | 681 | 'LIN_type' => EEM_Line_Item::type_tax |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | $new_tax_subtotal |
686 | 686 | ); |
687 | 687 | $new_tax_subtotal->save(); |
688 | - $tax_subtotal->set_total( $amount ); |
|
688 | + $tax_subtotal->set_total($amount); |
|
689 | 689 | $tax_subtotal->save(); |
690 | 690 | $total_line_item->recalculate_total_including_taxes(); |
691 | 691 | return $new_tax_subtotal; |
@@ -700,8 +700,8 @@ discard block |
||
700 | 700 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
701 | 701 | * @return EE_Line_Item[] |
702 | 702 | */ |
703 | - public static function get_event_subtotals( EE_Line_Item $parent_line_item ) { |
|
704 | - return self::get_subtotals_of_object_type( $parent_line_item, 'Event' ); |
|
703 | + public static function get_event_subtotals(EE_Line_Item $parent_line_item) { |
|
704 | + return self::get_subtotals_of_object_type($parent_line_item, 'Event'); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | |
@@ -714,8 +714,8 @@ discard block |
||
714 | 714 | * @param string $obj_type |
715 | 715 | * @return EE_Line_Item[] |
716 | 716 | */ |
717 | - public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
718 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_sub_total, $obj_type ); |
|
717 | + public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
718 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_sub_total, $obj_type); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
728 | 728 | * @return EE_Line_Item[] |
729 | 729 | */ |
730 | - public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) { |
|
731 | - return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' ); |
|
730 | + public static function get_ticket_line_items(EE_Line_Item $parent_line_item) { |
|
731 | + return self::get_line_items_of_object_type($parent_line_item, 'Ticket'); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | |
@@ -741,8 +741,8 @@ discard block |
||
741 | 741 | * @param string $obj_type |
742 | 742 | * @return EE_Line_Item[] |
743 | 743 | */ |
744 | - public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
745 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type ); |
|
744 | + public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
745 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | |
@@ -753,8 +753,8 @@ discard block |
||
753 | 753 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
754 | 754 | * @return EE_Line_Item[] |
755 | 755 | */ |
756 | - public static function get_tax_descendants( EE_Line_Item $parent_line_item ) { |
|
757 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax ); |
|
756 | + public static function get_tax_descendants(EE_Line_Item $parent_line_item) { |
|
757 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | |
@@ -765,8 +765,8 @@ discard block |
||
765 | 765 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
766 | 766 | * @return EE_Line_Item[] |
767 | 767 | */ |
768 | - public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) { |
|
769 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item ); |
|
768 | + public static function get_line_item_descendants(EE_Line_Item $parent_line_item) { |
|
769 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item); |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | |
@@ -779,8 +779,8 @@ discard block |
||
779 | 779 | * @param string $line_item_type one of the EEM_Line_Item constants |
780 | 780 | * @return EE_Line_Item[] |
781 | 781 | */ |
782 | - public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) { |
|
783 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL ); |
|
782 | + public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) { |
|
783 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
@@ -793,15 +793,15 @@ discard block |
||
793 | 793 | * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching |
794 | 794 | * @return EE_Line_Item[] |
795 | 795 | */ |
796 | - protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) { |
|
796 | + protected static function _get_descendants_by_type_and_object_type(EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL) { |
|
797 | 797 | $objects = array(); |
798 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
799 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
800 | - if ( $child_line_item->type() == $line_item_type && ( $child_line_item->OBJ_type() == $obj_type || $obj_type === NULL )) { |
|
798 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
799 | + if ($child_line_item instanceof EE_Line_Item) { |
|
800 | + if ($child_line_item->type() == $line_item_type && ($child_line_item->OBJ_type() == $obj_type || $obj_type === NULL)) { |
|
801 | 801 | $objects[] = $child_line_item; |
802 | 802 | } else { |
803 | 803 | //go-through-all-its children looking for more matches |
804 | - $objects = array_merge( $objects, self::_get_descendants_by_type_and_object_type( $child_line_item, $line_item_type, $obj_type )); |
|
804 | + $objects = array_merge($objects, self::_get_descendants_by_type_and_object_type($child_line_item, $line_item_type, $obj_type)); |
|
805 | 805 | } |
806 | 806 | } |
807 | 807 | } |
@@ -819,8 +819,8 @@ discard block |
||
819 | 819 | * @param array $OBJ_IDs array of OBJ_IDs |
820 | 820 | * @return EE_Line_Item[] |
821 | 821 | */ |
822 | - public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) { |
|
823 | - return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs ); |
|
822 | + public static function get_line_items_by_object_type_and_IDs(EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array()) { |
|
823 | + return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs); |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -833,15 +833,15 @@ discard block |
||
833 | 833 | * @param array $OBJ_IDs array of OBJ_IDs |
834 | 834 | * @return EE_Line_Item[] |
835 | 835 | */ |
836 | - protected static function _get_descendants_by_object_type_and_object_ID( EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs ) { |
|
836 | + protected static function _get_descendants_by_object_type_and_object_ID(EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs) { |
|
837 | 837 | $objects = array(); |
838 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
839 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
840 | - if ( is_array( $OBJ_IDs ) && $child_line_item->OBJ_type() == $OBJ_type && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )) { |
|
838 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
839 | + if ($child_line_item instanceof EE_Line_Item) { |
|
840 | + if (is_array($OBJ_IDs) && $child_line_item->OBJ_type() == $OBJ_type && in_array($child_line_item->OBJ_ID(), $OBJ_IDs)) { |
|
841 | 841 | $objects[] = $child_line_item; |
842 | 842 | } else { |
843 | 843 | //go-through-all-its children looking for more matches |
844 | - $objects = array_merge( $objects, self::_get_descendants_by_object_type_and_object_ID( $child_line_item, $OBJ_type, $OBJ_IDs )); |
|
844 | + $objects = array_merge($objects, self::_get_descendants_by_object_type_and_object_ID($child_line_item, $OBJ_type, $OBJ_IDs)); |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | } |
@@ -859,8 +859,8 @@ discard block |
||
859 | 859 | * @param string $type like one of the EEM_Line_Item::type_* |
860 | 860 | * @return EE_Line_Item |
861 | 861 | */ |
862 | - public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) { |
|
863 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type ); |
|
862 | + public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) { |
|
863 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | |
@@ -873,8 +873,8 @@ discard block |
||
873 | 873 | * @param string $code any value used for LIN_code |
874 | 874 | * @return EE_Line_Item |
875 | 875 | */ |
876 | - public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) { |
|
877 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code ); |
|
876 | + public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) { |
|
877 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | |
@@ -887,15 +887,15 @@ discard block |
||
887 | 887 | * @param string $value any value stored in $search_field |
888 | 888 | * @return EE_Line_Item |
889 | 889 | */ |
890 | - protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) { |
|
891 | - foreach( $parent_line_item->children() as $child ){ |
|
892 | - if ( $child->get( $search_field ) == $value ){ |
|
890 | + protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) { |
|
891 | + foreach ($parent_line_item->children() as $child) { |
|
892 | + if ($child->get($search_field) == $value) { |
|
893 | 893 | return $child; |
894 | 894 | } |
895 | 895 | } |
896 | - foreach( $parent_line_item->children() as $child ){ |
|
897 | - $descendant_found = self::_get_nearest_descendant( $child, $search_field, $value ); |
|
898 | - if ( $descendant_found ){ |
|
896 | + foreach ($parent_line_item->children() as $child) { |
|
897 | + $descendant_found = self::_get_nearest_descendant($child, $search_field, $value); |
|
898 | + if ($descendant_found) { |
|
899 | 899 | return $descendant_found; |
900 | 900 | } |
901 | 901 | } |
@@ -911,22 +911,22 @@ discard block |
||
911 | 911 | * @param int $indentation |
912 | 912 | * @return void |
913 | 913 | */ |
914 | - public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){ |
|
914 | + public static function visualize(EE_Line_Item $line_item, $indentation = 0) { |
|
915 | 915 | echo "\n<br />"; |
916 | - for( $i = 0; $i < $indentation; $i++ ){ |
|
916 | + for ($i = 0; $i < $indentation; $i++) { |
|
917 | 917 | echo " - "; |
918 | 918 | } |
919 | - if( $line_item->is_percent() ) { |
|
920 | - $breakdown = $line_item->percent() . '%'; |
|
919 | + if ($line_item->is_percent()) { |
|
920 | + $breakdown = $line_item->percent().'%'; |
|
921 | 921 | } else { |
922 | - $breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity(); |
|
922 | + $breakdown = '$'.$line_item->unit_price()."x".$line_item->quantity(); |
|
923 | 923 | } |
924 | - echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " $" . $line_item->total() . "(" . $breakdown . ")"; |
|
925 | - if( $line_item->is_taxable() ){ |
|
924 | + echo $line_item->name()."( ".$line_item->ID()." ) : ".$line_item->type()." $".$line_item->total()."(".$breakdown.")"; |
|
925 | + if ($line_item->is_taxable()) { |
|
926 | 926 | echo " * taxable"; |
927 | 927 | } |
928 | - if( $line_item->children() ){ |
|
929 | - foreach($line_item->children() as $child){ |
|
928 | + if ($line_item->children()) { |
|
929 | + foreach ($line_item->children() as $child) { |
|
930 | 930 | self::visualize($child, $indentation + 1); |
931 | 931 | } |
932 | 932 | } |
@@ -967,88 +967,88 @@ discard block |
||
967 | 967 | * is theirs, which can be done with |
968 | 968 | * `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );` |
969 | 969 | */ |
970 | - public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) { |
|
970 | + public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) { |
|
971 | 971 | //init running grand total if not already |
972 | - if ( ! isset( $running_totals[ 'total' ] ) ) { |
|
973 | - $running_totals[ 'total' ] = 0; |
|
972 | + if ( ! isset($running_totals['total'])) { |
|
973 | + $running_totals['total'] = 0; |
|
974 | 974 | } |
975 | - if( ! isset( $running_totals[ 'taxable' ] ) ) { |
|
976 | - $running_totals[ 'taxable' ] = array( 'total' => 0 ); |
|
975 | + if ( ! isset($running_totals['taxable'])) { |
|
976 | + $running_totals['taxable'] = array('total' => 0); |
|
977 | 977 | } |
978 | - foreach ( $line_item->children() as $child_line_item ) { |
|
979 | - switch ( $child_line_item->type() ) { |
|
978 | + foreach ($line_item->children() as $child_line_item) { |
|
979 | + switch ($child_line_item->type()) { |
|
980 | 980 | |
981 | 981 | case EEM_Line_Item::type_sub_total : |
982 | - $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities ); |
|
982 | + $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities); |
|
983 | 983 | //combine arrays but preserve numeric keys |
984 | - $running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals ); |
|
985 | - $running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ]; |
|
986 | - $running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ]; |
|
984 | + $running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals); |
|
985 | + $running_totals['total'] += $running_totals_from_subtotal['total']; |
|
986 | + $running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total']; |
|
987 | 987 | break; |
988 | 988 | |
989 | 989 | case EEM_Line_Item::type_tax_sub_total : |
990 | 990 | |
991 | 991 | //find how much the taxes percentage is |
992 | - if ( $child_line_item->percent() != 0 ) { |
|
992 | + if ($child_line_item->percent() != 0) { |
|
993 | 993 | $tax_percent_decimal = $child_line_item->percent() / 100; |
994 | 994 | } else { |
995 | 995 | $tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100; |
996 | 996 | } |
997 | 997 | //and apply to all the taxable totals, and add to the pretax totals |
998 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
998 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
999 | 999 | //"total" and "taxable" array key is an exception |
1000 | - if ( $line_item_id === 'taxable' ) { |
|
1000 | + if ($line_item_id === 'taxable') { |
|
1001 | 1001 | continue; |
1002 | 1002 | } |
1003 | - $taxable_total = $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1004 | - $running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal ); |
|
1003 | + $taxable_total = $running_totals['taxable'][$line_item_id]; |
|
1004 | + $running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal); |
|
1005 | 1005 | } |
1006 | 1006 | break; |
1007 | 1007 | |
1008 | 1008 | case EEM_Line_Item::type_line_item : |
1009 | 1009 | |
1010 | 1010 | // ticket line items or ???? |
1011 | - if ( $child_line_item->OBJ_type() === 'Ticket' ) { |
|
1011 | + if ($child_line_item->OBJ_type() === 'Ticket') { |
|
1012 | 1012 | // kk it's a ticket |
1013 | - if ( isset( $running_totals[ $child_line_item->ID() ] ) ) { |
|
1013 | + if (isset($running_totals[$child_line_item->ID()])) { |
|
1014 | 1014 | //huh? that shouldn't happen. |
1015 | - $running_totals[ 'total' ] += $child_line_item->total(); |
|
1015 | + $running_totals['total'] += $child_line_item->total(); |
|
1016 | 1016 | } else { |
1017 | 1017 | //its not in our running totals yet. great. |
1018 | - if ( $child_line_item->is_taxable() ) { |
|
1018 | + if ($child_line_item->is_taxable()) { |
|
1019 | 1019 | $taxable_amount = $child_line_item->unit_price(); |
1020 | 1020 | } else { |
1021 | 1021 | $taxable_amount = 0; |
1022 | 1022 | } |
1023 | 1023 | // are we only calculating totals for some tickets? |
1024 | - if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) { |
|
1025 | - $quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ]; |
|
1026 | - $running_totals[ $child_line_item->ID() ] = $quantity ? $child_line_item->unit_price() : 0; |
|
1027 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity ? $taxable_amount : 0; |
|
1024 | + if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) { |
|
1025 | + $quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()]; |
|
1026 | + $running_totals[$child_line_item->ID()] = $quantity ? $child_line_item->unit_price() : 0; |
|
1027 | + $running_totals['taxable'][$child_line_item->ID()] = $quantity ? $taxable_amount : 0; |
|
1028 | 1028 | } else { |
1029 | 1029 | $quantity = $child_line_item->quantity(); |
1030 | - $running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price(); |
|
1031 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount; |
|
1030 | + $running_totals[$child_line_item->ID()] = $child_line_item->unit_price(); |
|
1031 | + $running_totals['taxable'][$child_line_item->ID()] = $taxable_amount; |
|
1032 | 1032 | } |
1033 | - $running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity; |
|
1034 | - $running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity; |
|
1033 | + $running_totals['taxable']['total'] += $taxable_amount * $quantity; |
|
1034 | + $running_totals['total'] += $child_line_item->unit_price() * $quantity; |
|
1035 | 1035 | } |
1036 | 1036 | } else { |
1037 | 1037 | // it's some other type of item added to the cart |
1038 | 1038 | // it should affect the running totals |
1039 | 1039 | // basically we want to convert it into a PERCENT modifier. Because |
1040 | 1040 | // more clearly affect all registration's final price equally |
1041 | - $line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 : 1; |
|
1042 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1041 | + $line_items_percent_of_running_total = $running_totals['total'] > 0 ? ($child_line_item->total() / $running_totals['total']) + 1 : 1; |
|
1042 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1043 | 1043 | //the "taxable" array key is an exception |
1044 | - if ( $line_item_id === 'taxable' ) { |
|
1044 | + if ($line_item_id === 'taxable') { |
|
1045 | 1045 | continue; |
1046 | 1046 | } |
1047 | 1047 | // update the running totals |
1048 | 1048 | // yes this actually even works for the running grand total! |
1049 | - $running_totals[ $line_item_id ] = $line_items_percent_of_running_total * $this_running_total; |
|
1050 | - if ( $child_line_item->is_taxable() ) { |
|
1051 | - $running_totals[ 'taxable' ][ $line_item_id ] = $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1049 | + $running_totals[$line_item_id] = $line_items_percent_of_running_total * $this_running_total; |
|
1050 | + if ($child_line_item->is_taxable()) { |
|
1051 | + $running_totals['taxable'][$line_item_id] = $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id]; |
|
1052 | 1052 | } |
1053 | 1053 | } |
1054 | 1054 | } |
@@ -1067,15 +1067,15 @@ discard block |
||
1067 | 1067 | * @param EE_Registration[] $registrations |
1068 | 1068 | * @return \EE_Line_Item |
1069 | 1069 | */ |
1070 | - public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) { |
|
1071 | - $copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations ); |
|
1072 | - foreach ( $line_item->children() as $child_li ) { |
|
1073 | - $copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) ); |
|
1070 | + public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) { |
|
1071 | + $copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations); |
|
1072 | + foreach ($line_item->children() as $child_li) { |
|
1073 | + $copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations)); |
|
1074 | 1074 | } |
1075 | 1075 | //if this is the grand total line item, make sure the totals all add up |
1076 | 1076 | //(we could have duplicated this logic AS we copied the line items, but |
1077 | 1077 | //it seems DRYer this way) |
1078 | - if ( $copy_li->type() === EEM_Line_Item::type_total ) { |
|
1078 | + if ($copy_li->type() === EEM_Line_Item::type_total) { |
|
1079 | 1079 | $copy_li->recalculate_total_including_taxes(); |
1080 | 1080 | } |
1081 | 1081 | return $copy_li; |
@@ -1090,26 +1090,26 @@ discard block |
||
1090 | 1090 | * @return EE_Line_Item |
1091 | 1091 | * @param EE_Registration[] $registrations |
1092 | 1092 | */ |
1093 | - public static function billable_line_item( EE_Line_Item $line_item, $registrations ) { |
|
1093 | + public static function billable_line_item(EE_Line_Item $line_item, $registrations) { |
|
1094 | 1094 | $new_li_fields = $line_item->model_field_array(); |
1095 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1095 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1096 | 1096 | $line_item->OBJ_type() === 'Ticket' |
1097 | 1097 | ) { |
1098 | 1098 | $count = 0; |
1099 | - foreach ( $registrations as $registration ) { |
|
1100 | - if ( $line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1101 | - in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() ) |
|
1099 | + foreach ($registrations as $registration) { |
|
1100 | + if ($line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1101 | + in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment()) |
|
1102 | 1102 | ) { |
1103 | 1103 | $count++; |
1104 | 1104 | } |
1105 | 1105 | } |
1106 | - $new_li_fields[ 'LIN_quantity' ] = $count; |
|
1106 | + $new_li_fields['LIN_quantity'] = $count; |
|
1107 | 1107 | } |
1108 | 1108 | //don't set the total. We'll leave that up to the code that calculates it |
1109 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1110 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1111 | - unset( $new_li_fields[ 'LIN_total' ] ); |
|
1112 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1109 | + unset($new_li_fields['LIN_ID']); |
|
1110 | + unset($new_li_fields['LIN_parent']); |
|
1111 | + unset($new_li_fields['LIN_total']); |
|
1112 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | |
@@ -1121,19 +1121,19 @@ discard block |
||
1121 | 1121 | * @param EE_Line_Item $line_item |null |
1122 | 1122 | * @return \EE_Line_Item|null |
1123 | 1123 | */ |
1124 | - public static function non_empty_line_items( EE_Line_Item $line_item ) { |
|
1125 | - $copied_li = EEH_Line_Item::non_empty_line_item( $line_item ); |
|
1126 | - if ( $copied_li === null ) { |
|
1124 | + public static function non_empty_line_items(EE_Line_Item $line_item) { |
|
1125 | + $copied_li = EEH_Line_Item::non_empty_line_item($line_item); |
|
1126 | + if ($copied_li === null) { |
|
1127 | 1127 | return null; |
1128 | 1128 | } |
1129 | 1129 | //if this is an event subtotal, we want to only include it if it |
1130 | 1130 | //has a non-zero total and at least one ticket line item child |
1131 | 1131 | $ticket_children = 0; |
1132 | - foreach ( $line_item->children() as $child_li ) { |
|
1133 | - $child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li ); |
|
1134 | - if ( $child_li_copy !== null ) { |
|
1135 | - $copied_li->add_child_line_item( $child_li_copy ); |
|
1136 | - if ( $child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1132 | + foreach ($line_item->children() as $child_li) { |
|
1133 | + $child_li_copy = EEH_Line_Item::non_empty_line_items($child_li); |
|
1134 | + if ($child_li_copy !== null) { |
|
1135 | + $copied_li->add_child_line_item($child_li_copy); |
|
1136 | + if ($child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1137 | 1137 | $child_li_copy->OBJ_type() === 'Ticket' |
1138 | 1138 | ) { |
1139 | 1139 | $ticket_children++; |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | } |
1143 | 1143 | //if this is an event subtotal with NO ticket children |
1144 | 1144 | //we basically want to ignore it |
1145 | - if ( $line_item->type() === EEM_Line_Item::type_sub_total && |
|
1145 | + if ($line_item->type() === EEM_Line_Item::type_sub_total && |
|
1146 | 1146 | $line_item->OBJ_type() === 'Event' && |
1147 | 1147 | $ticket_children === 0 && |
1148 | 1148 | $line_item->total() === 0 |
@@ -1160,8 +1160,8 @@ discard block |
||
1160 | 1160 | * @param EE_Line_Item $line_item |
1161 | 1161 | * @return EE_Line_Item |
1162 | 1162 | */ |
1163 | - public static function non_empty_line_item( EE_Line_Item $line_item ) { |
|
1164 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1163 | + public static function non_empty_line_item(EE_Line_Item $line_item) { |
|
1164 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1165 | 1165 | $line_item->OBJ_type() === 'Ticket' && |
1166 | 1166 | $line_item->quantity() == 0 |
1167 | 1167 | ) { |
@@ -1169,9 +1169,9 @@ discard block |
||
1169 | 1169 | } |
1170 | 1170 | $new_li_fields = $line_item->model_field_array(); |
1171 | 1171 | //don't set the total. We'll leave that up to the code that calculates it |
1172 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1173 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1174 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1172 | + unset($new_li_fields['LIN_ID']); |
|
1173 | + unset($new_li_fields['LIN_parent']); |
|
1174 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | |
@@ -1185,9 +1185,9 @@ discard block |
||
1185 | 1185 | * @param EE_Line_Item $total_line_item |
1186 | 1186 | * @return \EE_Line_Item |
1187 | 1187 | */ |
1188 | - public static function get_items_subtotal( EE_Line_Item $total_line_item ){ |
|
1189 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1190 | - return self::get_pre_tax_subtotal( $total_line_item ); |
|
1188 | + public static function get_items_subtotal(EE_Line_Item $total_line_item) { |
|
1189 | + EE_Error::doing_it_wrong('EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1190 | + return self::get_pre_tax_subtotal($total_line_item); |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | |
@@ -1197,9 +1197,9 @@ discard block |
||
1197 | 1197 | * @param EE_Transaction $transaction |
1198 | 1198 | * @return \EE_Line_Item |
1199 | 1199 | */ |
1200 | - public static function create_default_total_line_item( $transaction = NULL) { |
|
1201 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0' ); |
|
1202 | - return self::create_total_line_item( $transaction ); |
|
1200 | + public static function create_default_total_line_item($transaction = NULL) { |
|
1201 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0'); |
|
1202 | + return self::create_total_line_item($transaction); |
|
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
@@ -1210,9 +1210,9 @@ discard block |
||
1210 | 1210 | * @param EE_Transaction $transaction |
1211 | 1211 | * @return \EE_Line_Item |
1212 | 1212 | */ |
1213 | - public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1214 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1215 | - return self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
1213 | + public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1214 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1215 | + return self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | |
@@ -1223,9 +1223,9 @@ discard block |
||
1223 | 1223 | * @param EE_Transaction $transaction |
1224 | 1224 | * @return \EE_Line_Item |
1225 | 1225 | */ |
1226 | - public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1227 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1228 | - return self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
1226 | + public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1227 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0'); |
|
1228 | + return self::create_taxes_subtotal($total_line_item, $transaction); |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | |
@@ -1236,9 +1236,9 @@ discard block |
||
1236 | 1236 | * @param EE_Transaction $transaction |
1237 | 1237 | * @return \EE_Line_Item |
1238 | 1238 | */ |
1239 | - public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1240 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1241 | - return self::create_event_subtotal( $total_line_item, $transaction ); |
|
1239 | + public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1240 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0'); |
|
1241 | + return self::create_event_subtotal($total_line_item, $transaction); |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 |
@@ -467,15 +467,15 @@ |
||
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
470 | - * Given the grand total line item and a ticket, finds the event sub-total |
|
471 | - * line item the ticket's purchase should be added onto |
|
472 | - * |
|
473 | - * @access public |
|
474 | - * @param EE_Line_Item $grand_total the grand total line item |
|
475 | - * @param EE_Ticket $ticket |
|
476 | - * @throws \EE_Error |
|
477 | - * @return EE_Line_Item |
|
478 | - */ |
|
470 | + * Given the grand total line item and a ticket, finds the event sub-total |
|
471 | + * line item the ticket's purchase should be added onto |
|
472 | + * |
|
473 | + * @access public |
|
474 | + * @param EE_Line_Item $grand_total the grand total line item |
|
475 | + * @param EE_Ticket $ticket |
|
476 | + * @throws \EE_Error |
|
477 | + * @return EE_Line_Item |
|
478 | + */ |
|
479 | 479 | public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
480 | 480 | $first_datetime = $ticket->first_datetime(); |
481 | 481 | if( ! $first_datetime instanceof EE_Datetime ){ |
@@ -31,7 +31,6 @@ discard block |
||
31 | 31 | |
32 | 32 | /** |
33 | 33 | * google_map - creates a Google Map Link |
34 | - * @param array $atts aray of attributes required for the map link generation |
|
35 | 34 | * @return string (link to map!) |
36 | 35 | */ |
37 | 36 | public static function google_map( $ee_gmaps_opts ){ |
@@ -116,7 +115,6 @@ discard block |
||
116 | 115 | |
117 | 116 | /** |
118 | 117 | * creates a Google Map Link |
119 | - * @param array $atts aray of attributes required for the map link generation |
|
120 | 118 | * @return string (link to map!) |
121 | 119 | */ |
122 | 120 | public static function espresso_google_map_js() { |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | * @param array $atts aray of attributes required for the map link generation |
35 | 35 | * @return string (link to map!) |
36 | 36 | */ |
37 | - public static function google_map( $ee_gmaps_opts ){ |
|
37 | + public static function google_map($ee_gmaps_opts) { |
|
38 | 38 | |
39 | 39 | //d( $ee_gmaps_opts ); |
40 | 40 | |
41 | - $ee_map_width = isset( $ee_gmaps_opts['ee_map_width'] ) && ! empty( $ee_gmaps_opts['ee_map_width'] ) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | - $ee_map_height = isset( $ee_gmaps_opts['ee_map_height'] ) && ! empty( $ee_gmaps_opts['ee_map_height'] ) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | - $ee_map_zoom = isset( $ee_gmaps_opts['ee_map_zoom'] ) && ! empty( $ee_gmaps_opts['ee_map_zoom'] ) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | - $ee_map_nav_display = isset( $ee_gmaps_opts['ee_map_nav_display'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_display'] ) ? 'true' : 'false'; |
|
45 | - $ee_map_nav_size = isset( $ee_gmaps_opts['ee_map_nav_size'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_size'] )? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | - $ee_map_type_control = isset( $ee_gmaps_opts['ee_map_type_control'] ) && ! empty( $ee_gmaps_opts['ee_map_type_control'] )? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | - $static_url = isset( $ee_gmaps_opts['ee_static_url'] ) && ! empty( $ee_gmaps_opts['ee_static_url'] )? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
41 | + $ee_map_width = isset($ee_gmaps_opts['ee_map_width']) && ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
|
42 | + $ee_map_height = isset($ee_gmaps_opts['ee_map_height']) && ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
|
43 | + $ee_map_zoom = isset($ee_gmaps_opts['ee_map_zoom']) && ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
|
44 | + $ee_map_nav_display = isset($ee_gmaps_opts['ee_map_nav_display']) && ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
|
45 | + $ee_map_nav_size = isset($ee_gmaps_opts['ee_map_nav_size']) && ! empty($ee_gmaps_opts['ee_map_nav_size']) ? $ee_gmaps_opts['ee_map_nav_size'] : 'default'; |
|
46 | + $ee_map_type_control = isset($ee_gmaps_opts['ee_map_type_control']) && ! empty($ee_gmaps_opts['ee_map_type_control']) ? $ee_gmaps_opts['ee_map_type_control'] : 'default'; |
|
47 | + $static_url = isset($ee_gmaps_opts['ee_static_url']) && ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : FALSE; |
|
48 | 48 | |
49 | - if( isset( $ee_gmaps_opts['ee_map_align'] ) && ! empty( $ee_gmaps_opts['ee_map_align'] )){ |
|
50 | - switch( $ee_gmaps_opts['ee_map_align'] ){ |
|
49 | + if (isset($ee_gmaps_opts['ee_map_align']) && ! empty($ee_gmaps_opts['ee_map_align'])) { |
|
50 | + switch ($ee_gmaps_opts['ee_map_align']) { |
|
51 | 51 | case "left": |
52 | 52 | $map_align = 'ee-gmap-align-left left'; |
53 | 53 | break; |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | |
69 | 69 | // Determine whether user has set a hardoded url to use and |
70 | 70 | // if so display a Google static iframe map else run V3 api |
71 | - if( $static_url ) { |
|
71 | + if ($static_url) { |
|
72 | 72 | |
73 | - $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
|
74 | - $html .= '<iframe src="' . $static_url . '&output=embed" style="width: ' . $ee_map_width .'px; height: ' . $ee_map_height . 'px;" frameborder="0" scrolling="no">'; |
|
73 | + $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">'; |
|
74 | + $html .= '<iframe src="'.$static_url.'&output=embed" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;" frameborder="0" scrolling="no">'; |
|
75 | 75 | $html .= '</iframe>'; |
76 | - $html .= '<a href="' . $static_url . '">View Large map</a>'; |
|
76 | + $html .= '<a href="'.$static_url.'">View Large map</a>'; |
|
77 | 77 | $html .= '</div>'; |
78 | 78 | return $html; |
79 | 79 | |
80 | 80 | } else { |
81 | 81 | |
82 | - EEH_Maps::$gmap_vars[ $ee_gmaps_opts['map_ID'] ] = array( |
|
82 | + EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
|
83 | 83 | 'map_ID' => $ee_gmaps_opts['map_ID'], |
84 | 84 | 'ee_map_zoom' => $ee_map_zoom, |
85 | 85 | 'ee_map_nav_display' => $ee_map_nav_display, |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | ); |
90 | 90 | |
91 | 91 | $html = '<div class="ee-gmap-wrapper '.$map_align.';">'; |
92 | - $html .= '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] .'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
92 | + $html .= '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; // |
|
93 | 93 | $html .= '</div>'; |
94 | 94 | |
95 | - wp_enqueue_script( 'gmap_api' ); |
|
96 | - wp_enqueue_script( 'ee_gmap' ); |
|
97 | - add_action( 'wp_footer', array( 'EEH_Maps', 'footer_enqueue_script' )); |
|
95 | + wp_enqueue_script('gmap_api'); |
|
96 | + wp_enqueue_script('ee_gmap'); |
|
97 | + add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
|
98 | 98 | |
99 | 99 | return $html; |
100 | 100 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return void |
110 | 110 | */ |
111 | 111 | public static function footer_enqueue_script() { |
112 | - wp_localize_script( 'ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars ); |
|
112 | + wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function espresso_google_map_js() { |
123 | 123 | $scheme = is_ssl() ? 'https://' : 'http://'; |
124 | - wp_register_script( 'gmap_api', $scheme . 'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE ); |
|
125 | - wp_register_script( 'ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE ); |
|
124 | + wp_register_script('gmap_api', $scheme.'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE); |
|
125 | + wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return string (link to map!) |
132 | 132 | */ |
133 | 133 | public static function google_map_link($atts) { |
134 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
134 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
135 | 135 | extract($atts); |
136 | 136 | |
137 | 137 | $address = "{$address}"; |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | $id = isset($id) ? $id : 'not_set'; |
147 | 147 | $map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view'; |
148 | 148 | |
149 | - $address_string = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : ''); |
|
149 | + $address_string = ($address != '' ? $address : '').($city != '' ? ','.$city : '').($state != '' ? ','.$state : '').($zip != '' ? ','.$zip : '').($country != '' ? ','.$country : ''); |
|
150 | 150 | |
151 | - $google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode( $address_string )); |
|
151 | + $google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string)); |
|
152 | 152 | |
153 | 153 | switch ($type) { |
154 | 154 | case 'text': |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | |
163 | 163 | case 'map': |
164 | 164 | $scheme = is_ssl() ? 'https://' : 'http://'; |
165 | - return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2( $scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode( $address_string ) . '&zoom=14&size=' . $map_w . 'x' . $map_h . '&markers=color:green|label:|' . urlencode( $address_string ) . '&sensor=false' ) . '" /></a>'; |
|
165 | + return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&zoom=14&size='.$map_w.'x'.$map_h.'&markers=color:green|label:|'.urlencode($address_string).'&sensor=false').'" /></a>'; |
|
166 | 166 | } |
167 | 167 | |
168 | - return '<a href="' . $google_map . '" target="_blank">' . $text . '</a>'; |
|
168 | + return '<a href="'.$google_map.'" target="_blank">'.$text.'</a>'; |
|
169 | 169 | } |
170 | 170 | |
171 | 171 |