@@ -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 |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | * |
943 | 943 | * @access public |
944 | 944 | * @param string $return_url |
945 | - * @return array |
|
945 | + * @return string |
|
946 | 946 | */ |
947 | 947 | public static function get_persistent_admin_notices( $return_url = '' ) { |
948 | 948 | $notices = ''; |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | * |
968 | 968 | * @access public |
969 | 969 | * @param bool $force_print |
970 | - * @return void |
|
970 | + * @return null|string |
|
971 | 971 | */ |
972 | 972 | private static function _print_scripts( $force_print = FALSE ) { |
973 | 973 | if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | |
1106 | 1106 | /** |
1107 | 1107 | * Like get_notices, but returns an array of all the notices of the given type. |
1108 | - * @return array { |
|
1108 | + * @return boolean { |
|
1109 | 1109 | * @type array $success all the success messages |
1110 | 1110 | * @type array $errors all the error messages |
1111 | 1111 | * @type array $attention all the attention messages |
@@ -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,32 +613,32 @@ 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 |
631 | - $notice_code = EE_Error::generate_error_code( $file, $func, $line ); |
|
632 | - if ( WP_DEBUG && $type == 'errors' ) { |
|
633 | - $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
631 | + $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
632 | + if (WP_DEBUG && $type == 'errors') { |
|
633 | + $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>'; |
|
634 | 634 | } |
635 | 635 | // add notice. Index by code if it's not blank |
636 | - if( $notice_code ) { |
|
637 | - self::$_espresso_notices[ $type ][ $notice_code ] = $msg; |
|
636 | + if ($notice_code) { |
|
637 | + self::$_espresso_notices[$type][$notice_code] = $msg; |
|
638 | 638 | } else { |
639 | - self::$_espresso_notices[ $type ][] = $msg; |
|
639 | + self::$_espresso_notices[$type][] = $msg; |
|
640 | 640 | } |
641 | - add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 ); |
|
641 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | } |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * @access private |
693 | 693 | * @return void |
694 | 694 | */ |
695 | - public static function reset_notices(){ |
|
695 | + public static function reset_notices() { |
|
696 | 696 | self::$_espresso_notices['success'] = FALSE; |
697 | 697 | self::$_espresso_notices['attention'] = FALSE; |
698 | 698 | self::$_espresso_notices['errors'] = FALSE; |
@@ -705,14 +705,14 @@ discard block |
||
705 | 705 | * @access public |
706 | 706 | * @return int |
707 | 707 | */ |
708 | - public static function has_notices(){ |
|
708 | + public static function has_notices() { |
|
709 | 709 | $has_notices = 0; |
710 | 710 | // check for success messages |
711 | - $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
|
711 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices; |
|
712 | 712 | // check for attention messages |
713 | - $has_notices = self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ? 2 : $has_notices; |
|
713 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices; |
|
714 | 714 | // check for error messages |
715 | - $has_notices = self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ? 1 : $has_notices; |
|
715 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices; |
|
716 | 716 | return $has_notices; |
717 | 717 | } |
718 | 718 | |
@@ -728,8 +728,8 @@ discard block |
||
728 | 728 | * @param boolean $remove_empty whether or not to unset empty messages |
729 | 729 | * @return array |
730 | 730 | */ |
731 | - public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
|
732 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
731 | + public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) { |
|
732 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
733 | 733 | |
734 | 734 | $success_messages = ''; |
735 | 735 | $attention_messages = ''; |
@@ -739,44 +739,44 @@ discard block |
||
739 | 739 | // 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' ); |
740 | 740 | |
741 | 741 | // either save notices to the db |
742 | - if ( $save_to_transient ) { |
|
743 | - update_option( 'ee_notices', self::$_espresso_notices ); |
|
742 | + if ($save_to_transient) { |
|
743 | + update_option('ee_notices', self::$_espresso_notices); |
|
744 | 744 | return; |
745 | 745 | } |
746 | 746 | // grab any notices that have been previously saved |
747 | - if ( $notices = get_option( 'ee_notices', FALSE )) { |
|
748 | - foreach ( $notices as $type => $notice ) { |
|
749 | - if ( is_array( $notice ) && ! empty( $notice )) { |
|
747 | + if ($notices = get_option('ee_notices', FALSE)) { |
|
748 | + foreach ($notices as $type => $notice) { |
|
749 | + if (is_array($notice) && ! empty($notice)) { |
|
750 | 750 | // make sure that existsing notice type is an array |
751 | - self::$_espresso_notices[ $type ] = is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array(); |
|
751 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array(); |
|
752 | 752 | // merge stored notices with any newly created ones |
753 | - self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice ); |
|
753 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
754 | 754 | $print_scripts = TRUE; |
755 | 755 | } |
756 | 756 | } |
757 | 757 | // now clear any stored notices |
758 | - update_option( 'ee_notices', FALSE ); |
|
758 | + update_option('ee_notices', FALSE); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | // check for success messages |
762 | - if ( self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] )) { |
|
762 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
763 | 763 | // combine messages |
764 | - $success_messages .= implode( self::$_espresso_notices['success'], '<br />' ); |
|
764 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br />'); |
|
765 | 765 | $print_scripts = TRUE; |
766 | 766 | } |
767 | 767 | |
768 | 768 | // check for attention messages |
769 | - if ( self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ) { |
|
769 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
770 | 770 | // combine messages |
771 | - $attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' ); |
|
771 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />'); |
|
772 | 772 | $print_scripts = TRUE; |
773 | 773 | } |
774 | 774 | |
775 | 775 | // check for error messages |
776 | - if ( self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ) { |
|
777 | - $error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' ); |
|
776 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
777 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso'); |
|
778 | 778 | // combine messages |
779 | - $error_messages .= implode( self::$_espresso_notices['errors'], '<br />' ); |
|
779 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br />'); |
|
780 | 780 | $print_scripts = TRUE; |
781 | 781 | } |
782 | 782 | |
@@ -790,21 +790,21 @@ discard block |
||
790 | 790 | $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
791 | 791 | $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
792 | 792 | //showMessage( $success_messages ); |
793 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>'; |
|
793 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>'; |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | if ($attention_messages != '') { |
797 | 797 | $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
798 | 798 | $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
799 | 799 | //showMessage( $error_messages, TRUE ); |
800 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>'; |
|
800 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>'; |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | if ($error_messages != '') { |
804 | 804 | $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
805 | 805 | $css_class = is_admin() ? 'error' : 'error fade-away'; |
806 | 806 | //showMessage( $error_messages, TRUE ); |
807 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>'; |
|
807 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>'; |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | $notices .= '</div>'; |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | 'errors' => $error_messages |
818 | 818 | ); |
819 | 819 | |
820 | - if ( $remove_empty ) { |
|
820 | + if ($remove_empty) { |
|
821 | 821 | // remove empty notices |
822 | 822 | foreach ($notices as $type => $notice) { |
823 | 823 | if (empty($notice)) { |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | } |
828 | 828 | } |
829 | 829 | |
830 | - if ( $print_scripts ) { |
|
830 | + if ($print_scripts) { |
|
831 | 831 | self::_print_scripts(); |
832 | 832 | } |
833 | 833 | |
@@ -847,17 +847,17 @@ discard block |
||
847 | 847 | * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
848 | 848 | * @return void |
849 | 849 | */ |
850 | - public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
|
851 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
852 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
850 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) { |
|
851 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
852 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
853 | 853 | //maybe initialize persistent_admin_notices |
854 | - if ( empty( $persistent_admin_notices )) { |
|
855 | - add_option( 'ee_pers_admin_notices', array(), '', 'no' ); |
|
854 | + if (empty($persistent_admin_notices)) { |
|
855 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
856 | 856 | } |
857 | - $pan_name = sanitize_key( $pan_name ); |
|
858 | - if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) { |
|
859 | - $persistent_admin_notices[ $pan_name ] = $pan_message; |
|
860 | - update_option( 'ee_pers_admin_notices', $persistent_admin_notices ); |
|
857 | + $pan_name = sanitize_key($pan_name); |
|
858 | + if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
859 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
860 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | } |
@@ -873,34 +873,34 @@ discard block |
||
873 | 873 | * @param bool $return_immediately |
874 | 874 | * @return void |
875 | 875 | */ |
876 | - public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) { |
|
877 | - $pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name; |
|
878 | - if ( ! empty( $pan_name )) { |
|
879 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
876 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) { |
|
877 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
878 | + if ( ! empty($pan_name)) { |
|
879 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
880 | 880 | // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
881 | - if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) { |
|
881 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
882 | 882 | // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
883 | - if ( $purge ) { |
|
884 | - unset( $persistent_admin_notices[ $pan_name ] ); |
|
883 | + if ($purge) { |
|
884 | + unset($persistent_admin_notices[$pan_name]); |
|
885 | 885 | } else { |
886 | - $persistent_admin_notices[ $pan_name ] = NULL; |
|
886 | + $persistent_admin_notices[$pan_name] = NULL; |
|
887 | 887 | } |
888 | - if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) { |
|
889 | - EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
888 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) { |
|
889 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
890 | 890 | } |
891 | 891 | } |
892 | 892 | } |
893 | - if ( $return_immediately ) { |
|
893 | + if ($return_immediately) { |
|
894 | 894 | return; |
895 | - } else if ( EE_Registry::instance()->REQ->ajax ) { |
|
895 | + } else if (EE_Registry::instance()->REQ->ajax) { |
|
896 | 896 | // grab any notices and concatenate into string |
897 | - echo json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE )))); |
|
897 | + echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE)))); |
|
898 | 898 | exit(); |
899 | 899 | } else { |
900 | 900 | // save errors to a transient to be displayed on next request (after redirect) |
901 | - EE_Error::get_notices( FALSE, TRUE ); |
|
902 | - $return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : ''; |
|
903 | - wp_safe_redirect( urldecode( $return_url )); |
|
901 | + EE_Error::get_notices(FALSE, TRUE); |
|
902 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
903 | + wp_safe_redirect(urldecode($return_url)); |
|
904 | 904 | } |
905 | 905 | } |
906 | 906 | |
@@ -915,20 +915,20 @@ discard block |
||
915 | 915 | * @param string $return_url URL to go back to aftger nag notice is dismissed |
916 | 916 | * @return string |
917 | 917 | */ |
918 | - public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
|
919 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
918 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') { |
|
919 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
920 | 920 | $args = array( |
921 | 921 | 'nag_notice' => $pan_name, |
922 | - 'return_url' => urlencode( $return_url ), |
|
922 | + 'return_url' => urlencode($return_url), |
|
923 | 923 | 'ajax_url' => WP_AJAX_URL, |
924 | - 'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' ) |
|
924 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso') |
|
925 | 925 | ); |
926 | - wp_localize_script( 'espresso_core', 'ee_dismiss', $args ); |
|
926 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
927 | 927 | return ' |
928 | - <div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
929 | - <p>' . $pan_message . '</p> |
|
930 | - <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '"> |
|
931 | - <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .' |
|
928 | + <div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
929 | + <p>' . $pan_message.'</p> |
|
930 | + <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'"> |
|
931 | + <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').' |
|
932 | 932 | </a> |
933 | 933 | <div style="clear:both;"></div> |
934 | 934 | </div>'; |
@@ -944,17 +944,17 @@ discard block |
||
944 | 944 | * @param string $return_url |
945 | 945 | * @return array |
946 | 946 | */ |
947 | - public static function get_persistent_admin_notices( $return_url = '' ) { |
|
947 | + public static function get_persistent_admin_notices($return_url = '') { |
|
948 | 948 | $notices = ''; |
949 | 949 | // check for persistent admin notices |
950 | - if ( $persistent_admin_notices = get_option( 'ee_pers_admin_notices', FALSE )) { |
|
950 | + if ($persistent_admin_notices = get_option('ee_pers_admin_notices', FALSE)) { |
|
951 | 951 | // load scripts |
952 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
953 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
954 | - wp_enqueue_script( 'ee_error_js' ); |
|
952 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
953 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
954 | + wp_enqueue_script('ee_error_js'); |
|
955 | 955 | // and display notices |
956 | - foreach( $persistent_admin_notices as $pan_name => $pan_message ) { |
|
957 | - $notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url ); |
|
956 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
957 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
958 | 958 | } |
959 | 959 | } |
960 | 960 | return $notices; |
@@ -969,26 +969,26 @@ discard block |
||
969 | 969 | * @param bool $force_print |
970 | 970 | * @return void |
971 | 971 | */ |
972 | - private static function _print_scripts( $force_print = FALSE ) { |
|
973 | - if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
|
974 | - if ( wp_script_is( 'ee_error_js', 'enqueued' )) { |
|
972 | + private static function _print_scripts($force_print = FALSE) { |
|
973 | + if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) { |
|
974 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
975 | 975 | return; |
976 | - } else if ( wp_script_is( 'ee_error_js', 'registered' )) { |
|
977 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
978 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
979 | - wp_enqueue_script( 'ee_error_js' ); |
|
980 | - wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG )); |
|
976 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
977 | + add_filter('FHEE_load_css', '__return_true'); |
|
978 | + add_filter('FHEE_load_js', '__return_true'); |
|
979 | + wp_enqueue_script('ee_error_js'); |
|
980 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG)); |
|
981 | 981 | } |
982 | 982 | } else { |
983 | 983 | return ' |
984 | 984 | <script> |
985 | 985 | /* <![CDATA[ */ |
986 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
986 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
987 | 987 | /* ]]> */ |
988 | 988 | </script> |
989 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
990 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
991 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
989 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
990 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
991 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
992 | 992 | '; |
993 | 993 | |
994 | 994 | } |
@@ -1022,11 +1022,11 @@ discard block |
||
1022 | 1022 | * @ param string $line |
1023 | 1023 | * @ return string |
1024 | 1024 | */ |
1025 | - public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
|
1026 | - $file = explode( '.', basename( $file )); |
|
1027 | - $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
|
1028 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
1029 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
1025 | + public static function generate_error_code($file = '', $func = '', $line = '') { |
|
1026 | + $file = explode('.', basename($file)); |
|
1027 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1028 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
1029 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
1030 | 1030 | return $error_code; |
1031 | 1031 | } |
1032 | 1032 | |
@@ -1042,37 +1042,37 @@ discard block |
||
1042 | 1042 | * @ param object $ex |
1043 | 1043 | * @ return void |
1044 | 1044 | */ |
1045 | - public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
|
1045 | + public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) { |
|
1046 | 1046 | |
1047 | - if ( ! $ex ) { |
|
1047 | + if ( ! $ex) { |
|
1048 | 1048 | return; |
1049 | 1049 | } |
1050 | 1050 | |
1051 | - if ( ! $time ) { |
|
1051 | + if ( ! $time) { |
|
1052 | 1052 | $time = time(); |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - $exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1056 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
1057 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1058 | - $exception_log .= 'Code: '. $ex['code'] . PHP_EOL; |
|
1059 | - $exception_log .= 'File: '. $ex['file'] . PHP_EOL; |
|
1060 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1061 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1062 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1063 | - $exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1064 | - |
|
1065 | - EE_Registry::instance()->load_helper( 'File' ); |
|
1055 | + $exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1056 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
1057 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
1058 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
1059 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
1060 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
1061 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
1062 | + $exception_log .= $ex['string'].PHP_EOL; |
|
1063 | + $exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1064 | + |
|
1065 | + EE_Registry::instance()->load_helper('File'); |
|
1066 | 1066 | try { |
1067 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ); |
|
1068 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' ); |
|
1069 | - if ( ! $clear ) { |
|
1067 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file); |
|
1068 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs'); |
|
1069 | + if ( ! $clear) { |
|
1070 | 1070 | //get existing log file and append new log info |
1071 | - $exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log; |
|
1071 | + $exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log; |
|
1072 | 1072 | } |
1073 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log ); |
|
1074 | - } catch( EE_Error $e ){ |
|
1075 | - EE_Error::add_error( sprintf( __( 'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() )); |
|
1073 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log); |
|
1074 | + } catch (EE_Error $e) { |
|
1075 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage())); |
|
1076 | 1076 | return; |
1077 | 1077 | } |
1078 | 1078 | |
@@ -1096,10 +1096,10 @@ discard block |
||
1096 | 1096 | * @param int $error_type |
1097 | 1097 | * @return void |
1098 | 1098 | */ |
1099 | - public static function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
1100 | - if ( defined('WP_DEBUG') && WP_DEBUG ) { |
|
1099 | + public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
1100 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1101 | 1101 | EE_Registry::instance()->load_helper('Debug_Tools'); |
1102 | - EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $error_type ); |
|
1102 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type); |
|
1103 | 1103 | } |
1104 | 1104 | } |
1105 | 1105 | |
@@ -1131,13 +1131,13 @@ discard block |
||
1131 | 1131 | */ |
1132 | 1132 | function espresso_error_enqueue_scripts() { |
1133 | 1133 | // js for error handling |
1134 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1135 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1134 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1135 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1136 | 1136 | } |
1137 | -if ( is_admin() ) { |
|
1138 | - add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1137 | +if (is_admin()) { |
|
1138 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1139 | 1139 | } else { |
1140 | - add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1140 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 |
@@ -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( |
@@ -648,11 +648,11 @@ discard block |
||
648 | 648 | |
649 | 649 | |
650 | 650 | /** |
651 | - * in some case it may be necessary to overwrite the existing success messages |
|
652 | - * |
|
653 | - * @access public |
|
654 | - * @return void |
|
655 | - */ |
|
651 | + * in some case it may be necessary to overwrite the existing success messages |
|
652 | + * |
|
653 | + * @access public |
|
654 | + * @return void |
|
655 | + */ |
|
656 | 656 | public static function overwrite_success() { |
657 | 657 | self::$_espresso_notices['success'] = FALSE; |
658 | 658 | } |
@@ -662,11 +662,11 @@ discard block |
||
662 | 662 | |
663 | 663 | |
664 | 664 | /** |
665 | - * in some case it may be necessary to overwrite the existing attention messages |
|
666 | - * |
|
667 | - * @access public |
|
668 | - * @return void |
|
669 | - */ |
|
665 | + * in some case it may be necessary to overwrite the existing attention messages |
|
666 | + * |
|
667 | + * @access public |
|
668 | + * @return void |
|
669 | + */ |
|
670 | 670 | public static function overwrite_attention() { |
671 | 671 | self::$_espresso_notices['attention'] = FALSE; |
672 | 672 | } |
@@ -676,11 +676,11 @@ discard block |
||
676 | 676 | |
677 | 677 | |
678 | 678 | /** |
679 | - * in some case it may be necessary to overwrite the existing error messages |
|
680 | - * |
|
681 | - * @access public |
|
682 | - * @return void |
|
683 | - */ |
|
679 | + * in some case it may be necessary to overwrite the existing error messages |
|
680 | + * |
|
681 | + * @access public |
|
682 | + * @return void |
|
683 | + */ |
|
684 | 684 | public static function overwrite_errors() { |
685 | 685 | self::$_espresso_notices['errors'] = FALSE; |
686 | 686 | } |
@@ -688,24 +688,24 @@ discard block |
||
688 | 688 | |
689 | 689 | |
690 | 690 | /** |
691 | - * reset_notices |
|
692 | - * @access private |
|
693 | - * @return void |
|
694 | - */ |
|
691 | + * reset_notices |
|
692 | + * @access private |
|
693 | + * @return void |
|
694 | + */ |
|
695 | 695 | public static function reset_notices(){ |
696 | - self::$_espresso_notices['success'] = FALSE; |
|
697 | - self::$_espresso_notices['attention'] = FALSE; |
|
698 | - self::$_espresso_notices['errors'] = FALSE; |
|
699 | - } |
|
696 | + self::$_espresso_notices['success'] = FALSE; |
|
697 | + self::$_espresso_notices['attention'] = FALSE; |
|
698 | + self::$_espresso_notices['errors'] = FALSE; |
|
699 | + } |
|
700 | 700 | |
701 | 701 | |
702 | 702 | |
703 | 703 | /** |
704 | - * has_errors |
|
705 | - * @access public |
|
706 | - * @return int |
|
707 | - */ |
|
708 | - public static function has_notices(){ |
|
704 | + * has_errors |
|
705 | + * @access public |
|
706 | + * @return int |
|
707 | + */ |
|
708 | + public static function has_notices(){ |
|
709 | 709 | $has_notices = 0; |
710 | 710 | // check for success messages |
711 | 711 | $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
@@ -719,15 +719,15 @@ discard block |
||
719 | 719 | |
720 | 720 | |
721 | 721 | /** |
722 | - * compile all error or success messages into one string |
|
723 | - * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them |
|
724 | - * |
|
725 | - * @access public |
|
726 | - * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
727 | - * @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 |
|
728 | - * @param boolean $remove_empty whether or not to unset empty messages |
|
729 | - * @return array |
|
730 | - */ |
|
722 | + * compile all error or success messages into one string |
|
723 | + * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them |
|
724 | + * |
|
725 | + * @access public |
|
726 | + * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
727 | + * @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 |
|
728 | + * @param boolean $remove_empty whether or not to unset empty messages |
|
729 | + * @return array |
|
730 | + */ |
|
731 | 731 | public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
732 | 732 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
733 | 733 | |
@@ -839,14 +839,14 @@ discard block |
||
839 | 839 | |
840 | 840 | |
841 | 841 | /** |
842 | - * add_persistent_admin_notice |
|
843 | - * |
|
844 | - * @access public |
|
845 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
846 | - * @param string $pan_message the message to be stored persistently until dismissed |
|
847 | - * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
848 | - * @return void |
|
849 | - */ |
|
842 | + * add_persistent_admin_notice |
|
843 | + * |
|
844 | + * @access public |
|
845 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
846 | + * @param string $pan_message the message to be stored persistently until dismissed |
|
847 | + * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
848 | + * @return void |
|
849 | + */ |
|
850 | 850 | public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
851 | 851 | if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
852 | 852 | $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
@@ -910,9 +910,9 @@ discard block |
||
910 | 910 | * display_persistent_admin_notices |
911 | 911 | * |
912 | 912 | * @access public |
913 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
914 | - * @param string $pan_name the message to be stored persistently until dismissed |
|
915 | - * @param string $return_url URL to go back to aftger nag notice is dismissed |
|
913 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
914 | + * @param string $pan_name the message to be stored persistently until dismissed |
|
915 | + * @param string $return_url URL to go back to aftger nag notice is dismissed |
|
916 | 916 | * @return string |
917 | 917 | */ |
918 | 918 | public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
@@ -1008,11 +1008,11 @@ discard block |
||
1008 | 1008 | |
1009 | 1009 | |
1010 | 1010 | /** |
1011 | - * enqueue_error_scripts |
|
1012 | - * |
|
1013 | - * @access public |
|
1014 | - * @return void |
|
1015 | - */ |
|
1011 | + * enqueue_error_scripts |
|
1012 | + * |
|
1013 | + * @access public |
|
1014 | + * @return void |
|
1015 | + */ |
|
1016 | 1016 | public static function enqueue_error_scripts() { |
1017 | 1017 | self::_print_scripts(); |
1018 | 1018 | } |
@@ -1020,15 +1020,15 @@ discard block |
||
1020 | 1020 | |
1021 | 1021 | |
1022 | 1022 | /** |
1023 | - * create error code from filepath, function name, |
|
1024 | - * and line number where exception or error was thrown |
|
1025 | - * |
|
1026 | - * @access public |
|
1027 | - * @ param string $file |
|
1028 | - * @ param string $func |
|
1029 | - * @ param string $line |
|
1030 | - * @ return string |
|
1031 | - */ |
|
1023 | + * create error code from filepath, function name, |
|
1024 | + * and line number where exception or error was thrown |
|
1025 | + * |
|
1026 | + * @access public |
|
1027 | + * @ param string $file |
|
1028 | + * @ param string $func |
|
1029 | + * @ param string $line |
|
1030 | + * @ return string |
|
1031 | + */ |
|
1032 | 1032 | public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
1033 | 1033 | $file = explode( '.', basename( $file )); |
1034 | 1034 | $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
@@ -1042,13 +1042,13 @@ discard block |
||
1042 | 1042 | |
1043 | 1043 | |
1044 | 1044 | /** |
1045 | - * write exception details to log file |
|
1046 | - * |
|
1047 | - * @access public |
|
1048 | - * @ param timestamp $time |
|
1049 | - * @ param object $ex |
|
1050 | - * @ return void |
|
1051 | - */ |
|
1045 | + * write exception details to log file |
|
1046 | + * |
|
1047 | + * @access public |
|
1048 | + * @ param timestamp $time |
|
1049 | + * @ param object $ex |
|
1050 | + * @ return void |
|
1051 | + */ |
|
1052 | 1052 | public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
1053 | 1053 | |
1054 | 1054 | if ( ! $ex ) { |
@@ -392,7 +392,7 @@ |
||
392 | 392 | * @ access public |
393 | 393 | * @ return void |
394 | 394 | * |
395 | - * @param mixed $var |
|
395 | + * @param string $var |
|
396 | 396 | * @param bool $var_name |
397 | 397 | * @param string $file |
398 | 398 | * @param int $line |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.0 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEH_Debug_Tools{ |
|
11 | +class EEH_Debug_Tools { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * instance of the EEH_Autoloader object |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | 43 | // check if class object is instantiated, and instantiated properly |
44 | - if ( ! self::$_instance instanceof EEH_Debug_Tools ) { |
|
44 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
45 | 45 | self::$_instance = new self(); |
46 | 46 | } |
47 | 47 | return self::$_instance; |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | */ |
58 | 58 | private function __construct() { |
59 | 59 | // load Kint PHP debugging library |
60 | - if ( ! class_exists( 'Kint' ) && file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){ |
|
60 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
61 | 61 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
62 | 62 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
63 | 63 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
64 | 64 | // so we've moved it to our test folder so that it is not included with production releases |
65 | 65 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
66 | - require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' ); |
|
66 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
67 | 67 | } |
68 | - if ( ! defined('DOING_AJAX') || ! isset( $_REQUEST['noheader'] ) || $_REQUEST['noheader'] != 'true' || ! isset( $_REQUEST['TB_iframe'] )) { |
|
68 | + if ( ! defined('DOING_AJAX') || ! isset($_REQUEST['noheader']) || $_REQUEST['noheader'] != 'true' || ! isset($_REQUEST['TB_iframe'])) { |
|
69 | 69 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
70 | 70 | } |
71 | - $plugin = basename( EE_PLUGIN_DIR_PATH ); |
|
72 | - add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
73 | - add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
74 | - add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' )); |
|
71 | + $plugin = basename(EE_PLUGIN_DIR_PATH); |
|
72 | + add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
73 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
74 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | public static function show_db_name() { |
85 | - if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) { |
|
86 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>'; |
|
85 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
86 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>'; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function espresso_session_footer_dump() { |
98 | - if ( class_exists('Kint') && function_exists( 'wp_get_current_user' ) && current_user_can('update_core') && ( defined('WP_DEBUG') && WP_DEBUG ) && ! defined('DOING_AJAX') && class_exists( 'EE_Registry' )) { |
|
99 | - Kint::dump( EE_Registry::instance()->SSN->id() ); |
|
100 | - Kint::dump( EE_Registry::instance()->SSN ); |
|
98 | + if (class_exists('Kint') && function_exists('wp_get_current_user') && current_user_can('update_core') && (defined('WP_DEBUG') && WP_DEBUG) && ! defined('DOING_AJAX') && class_exists('EE_Registry')) { |
|
99 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
100 | + Kint::dump(EE_Registry::instance()->SSN); |
|
101 | 101 | // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
102 | 102 | $this->espresso_list_hooked_functions(); |
103 | 103 | $this->show_times(); |
@@ -114,27 +114,27 @@ discard block |
||
114 | 114 | * @param bool $tag |
115 | 115 | * @return void |
116 | 116 | */ |
117 | - public function espresso_list_hooked_functions( $tag=FALSE ){ |
|
117 | + public function espresso_list_hooked_functions($tag = FALSE) { |
|
118 | 118 | global $wp_filter; |
119 | 119 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
120 | - if ( $tag ) { |
|
121 | - $hook[$tag]=$wp_filter[$tag]; |
|
122 | - if ( ! is_array( $hook[$tag] )) { |
|
123 | - trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING ); |
|
120 | + if ($tag) { |
|
121 | + $hook[$tag] = $wp_filter[$tag]; |
|
122 | + if ( ! is_array($hook[$tag])) { |
|
123 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
124 | 124 | return; |
125 | 125 | } |
126 | - echo '<h5>For Tag: '. $tag .'</h5>'; |
|
126 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
127 | 127 | } |
128 | 128 | else { |
129 | - $hook=$wp_filter; |
|
130 | - ksort( $hook ); |
|
129 | + $hook = $wp_filter; |
|
130 | + ksort($hook); |
|
131 | 131 | } |
132 | - foreach( $hook as $tag => $priorities ) { |
|
132 | + foreach ($hook as $tag => $priorities) { |
|
133 | 133 | echo "<br />>>>>>\t<strong>$tag</strong><br />"; |
134 | - ksort( $priorities ); |
|
135 | - foreach( $priorities as $priority => $function ){ |
|
134 | + ksort($priorities); |
|
135 | + foreach ($priorities as $priority => $function) { |
|
136 | 136 | echo $priority; |
137 | - foreach( $function as $name => $properties ) { |
|
137 | + foreach ($function as $name => $properties) { |
|
138 | 138 | echo "\t$name<br />"; |
139 | 139 | } |
140 | 140 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @param string $hook_name |
151 | 151 | * @return array |
152 | 152 | */ |
153 | - public static function registered_filter_callbacks( $hook_name = '' ) { |
|
153 | + public static function registered_filter_callbacks($hook_name = '') { |
|
154 | 154 | $filters = array(); |
155 | 155 | global $wp_filter; |
156 | - if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
157 | - $filters[ $hook_name ] = array(); |
|
158 | - foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) { |
|
159 | - $filters[ $hook_name ][ $priority ] = array(); |
|
160 | - foreach ( $callbacks as $callback ) { |
|
161 | - $filters[ $hook_name ][ $priority ][] = $callback['function']; |
|
156 | + if (isset($wp_filter[$hook_name])) { |
|
157 | + $filters[$hook_name] = array(); |
|
158 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
159 | + $filters[$hook_name][$priority] = array(); |
|
160 | + foreach ($callbacks as $callback) { |
|
161 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * start_timer |
172 | 172 | * @param null $timer_name |
173 | 173 | */ |
174 | - public function start_timer( $timer_name = NULL ){ |
|
175 | - $this->_start_times[$timer_name] = microtime( TRUE ); |
|
174 | + public function start_timer($timer_name = NULL) { |
|
175 | + $this->_start_times[$timer_name] = microtime(TRUE); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | * stop_timer |
182 | 182 | * @param string $timer_name |
183 | 183 | */ |
184 | - public function stop_timer($timer_name = 'default'){ |
|
185 | - if( isset( $this->_start_times[ $timer_name ] ) ){ |
|
186 | - $start_time = $this->_start_times[ $timer_name ]; |
|
187 | - unset( $this->_start_times[ $timer_name ] ); |
|
188 | - }else{ |
|
189 | - $start_time = array_pop( $this->_start_times ); |
|
184 | + public function stop_timer($timer_name = 'default') { |
|
185 | + if (isset($this->_start_times[$timer_name])) { |
|
186 | + $start_time = $this->_start_times[$timer_name]; |
|
187 | + unset($this->_start_times[$timer_name]); |
|
188 | + } else { |
|
189 | + $start_time = array_pop($this->_start_times); |
|
190 | 190 | } |
191 | - $total_time = microtime( TRUE ) - $start_time; |
|
192 | - switch ( $total_time ) { |
|
191 | + $total_time = microtime(TRUE) - $start_time; |
|
192 | + switch ($total_time) { |
|
193 | 193 | case $total_time < 0.00001 : |
194 | 194 | $color = '#8A549A'; |
195 | 195 | $bold = 'normal'; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $bold = 'bold'; |
216 | 216 | break; |
217 | 217 | } |
218 | - $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">' . number_format( $total_time, 8 ) . '</div> ' . $timer_name; |
|
218 | + $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">'.number_format($total_time, 8).'</div> '.$timer_name; |
|
219 | 219 | } |
220 | 220 | /** |
221 | 221 | * Measure the memory usage by PHP so far. |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - public function measure_memory( $label, $output_now = false ) { |
|
227 | - $memory_used = $this->convert( memory_get_peak_usage( true ) ); |
|
228 | - $this->_memory_usage_points[ $label ] = $memory_used; |
|
229 | - if( $output_now ) { |
|
226 | + public function measure_memory($label, $output_now = false) { |
|
227 | + $memory_used = $this->convert(memory_get_peak_usage(true)); |
|
228 | + $this->_memory_usage_points[$label] = $memory_used; |
|
229 | + if ($output_now) { |
|
230 | 230 | echo "\r\n<br>$label : $memory_used"; |
231 | 231 | } |
232 | 232 | } |
@@ -236,9 +236,9 @@ discard block |
||
236 | 236 | * @param int $size |
237 | 237 | * @return string |
238 | 238 | */ |
239 | - public function convert( $size ) { |
|
240 | - $unit=array('b','kb','mb','gb','tb','pb'); |
|
241 | - return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[ absint( $i ) ]; |
|
239 | + public function convert($size) { |
|
240 | + $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); |
|
241 | + return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[absint($i)]; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * @param bool $output_now |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function show_times($output_now=true){ |
|
252 | - $output = '<h2>Times:</h2>' . implode("<br>",$this->_times) . '<h2>Memory</h2>' . implode('<br>', $this->_memory_usage_points ); |
|
253 | - if($output_now){ |
|
251 | + public function show_times($output_now = true) { |
|
252 | + $output = '<h2>Times:</h2>'.implode("<br>", $this->_times).'<h2>Memory</h2>'.implode('<br>', $this->_memory_usage_points); |
|
253 | + if ($output_now) { |
|
254 | 254 | echo $output; |
255 | 255 | return ''; |
256 | 256 | } |
@@ -265,25 +265,25 @@ discard block |
||
265 | 265 | * @return void |
266 | 266 | */ |
267 | 267 | public static function ee_plugin_activation_errors() { |
268 | - if ( WP_DEBUG ) { |
|
268 | + if (WP_DEBUG) { |
|
269 | 269 | $activation_errors = ob_get_contents(); |
270 | - if ( ! empty( $activation_errors ) ) { |
|
271 | - $activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors; |
|
270 | + if ( ! empty($activation_errors)) { |
|
271 | + $activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors; |
|
272 | 272 | } |
273 | - espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' ); |
|
274 | - if ( class_exists( 'EEH_File' )) { |
|
273 | + espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php'); |
|
274 | + if (class_exists('EEH_File')) { |
|
275 | 275 | try { |
276 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' ); |
|
277 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
278 | - } catch( EE_Error $e ){ |
|
279 | - EE_Error::add_error( sprintf( __( 'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
276 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'); |
|
277 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
278 | + } catch (EE_Error $e) { |
|
279 | + EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
280 | 280 | } |
281 | 281 | } else { |
282 | 282 | // old school attempt |
283 | - file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
283 | + file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
284 | 284 | } |
285 | - $activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors; |
|
286 | - update_option( 'ee_plugin_activation_errors', $activation_errors ); |
|
285 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
286 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
@@ -299,22 +299,22 @@ discard block |
||
299 | 299 | * @param int $error_type |
300 | 300 | * @uses trigger_error() |
301 | 301 | */ |
302 | - public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
303 | - do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | - $version = is_null( $version ) ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version ); |
|
305 | - $error_message = sprintf( esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s','event_espresso' ), $function, '<strong>', '</strong>', $message, $version ); |
|
302 | + public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
303 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
304 | + $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version); |
|
305 | + $error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version); |
|
306 | 306 | |
307 | 307 | //don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request. |
308 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
309 | - $error_message .= esc_html__( 'This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso' ); |
|
308 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
309 | + $error_message .= esc_html__('This is a doing_it_wrong message that was triggered during an ajax request. The request params on this request were: ', 'event_espresso'); |
|
310 | 310 | $error_message .= '<ul><li>'; |
311 | - $error_message .= implode( '</li><li>', EE_Registry::instance()->REQ->params() ); |
|
311 | + $error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params()); |
|
312 | 312 | $error_message .= '</ul>'; |
313 | - EE_Error::add_error( $error_message, 'debug::doing_it_wrong', $function, '42' ); |
|
313 | + EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42'); |
|
314 | 314 | //now we set this on the transient so it shows up on the next request. |
315 | - EE_Error::get_notices( is_admin(), true ); |
|
315 | + EE_Error::get_notices(is_admin(), true); |
|
316 | 316 | } else { |
317 | - trigger_error( $error_message, $error_type ); |
|
317 | + trigger_error($error_message, $error_type); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
@@ -336,22 +336,22 @@ discard block |
||
336 | 336 | * @param string $debug_index |
337 | 337 | * @param string $debug_key |
338 | 338 | */ |
339 | - public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) { |
|
340 | - if ( WP_DEBUG && false ) { |
|
341 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
342 | - $debug_data = get_option( $debug_key, array() ); |
|
339 | + public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { |
|
340 | + if (WP_DEBUG && false) { |
|
341 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
342 | + $debug_data = get_option($debug_key, array()); |
|
343 | 343 | $default_data = array( |
344 | - $class => $func . '() : ' . $line, |
|
344 | + $class => $func.'() : '.$line, |
|
345 | 345 | 'REQ' => $display_request ? $_REQUEST : '', |
346 | 346 | ); |
347 | 347 | // don't serialize objects |
348 | - $info = self::strip_objects( $info ); |
|
349 | - $index = ! empty( $debug_index ) ? $debug_index : 0; |
|
350 | - if ( ! isset( $debug_data[$index] ) ) { |
|
348 | + $info = self::strip_objects($info); |
|
349 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
350 | + if ( ! isset($debug_data[$index])) { |
|
351 | 351 | $debug_data[$index] = array(); |
352 | 352 | } |
353 | - $debug_data[$index][microtime()] = array_merge( $default_data, $info ); |
|
354 | - update_option( $debug_key, $debug_data ); |
|
353 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
354 | + update_option($debug_key, $debug_data); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -363,26 +363,26 @@ discard block |
||
363 | 363 | * @param array $info |
364 | 364 | * @return array |
365 | 365 | */ |
366 | - public static function strip_objects( $info = array() ) { |
|
367 | - foreach ( $info as $key => $value ) { |
|
368 | - if ( is_array( $value ) ) { |
|
369 | - $info[ $key ] = self::strip_objects( $value ); |
|
370 | - } else if ( is_object( $value ) ) { |
|
371 | - $object_class = get_class( $value ); |
|
372 | - $info[ $object_class ] = array(); |
|
373 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value ); |
|
374 | - if ( method_exists( $value, 'ID' ) ) { |
|
375 | - $info[ $object_class ][ 'ID' ] = $value->ID(); |
|
366 | + public static function strip_objects($info = array()) { |
|
367 | + foreach ($info as $key => $value) { |
|
368 | + if (is_array($value)) { |
|
369 | + $info[$key] = self::strip_objects($value); |
|
370 | + } else if (is_object($value)) { |
|
371 | + $object_class = get_class($value); |
|
372 | + $info[$object_class] = array(); |
|
373 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
374 | + if (method_exists($value, 'ID')) { |
|
375 | + $info[$object_class]['ID'] = $value->ID(); |
|
376 | 376 | } |
377 | - if ( method_exists( $value, 'status' ) ) { |
|
378 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
379 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
380 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
377 | + if (method_exists($value, 'status')) { |
|
378 | + $info[$object_class]['status'] = $value->status(); |
|
379 | + } else if (method_exists($value, 'status_ID')) { |
|
380 | + $info[$object_class]['status'] = $value->status_ID(); |
|
381 | 381 | } |
382 | - unset( $info[ $key ] ); |
|
382 | + unset($info[$key]); |
|
383 | 383 | } |
384 | 384 | } |
385 | - return (array)$info; |
|
385 | + return (array) $info; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -399,24 +399,24 @@ discard block |
||
399 | 399 | * @param int $header |
400 | 400 | * @param bool $die |
401 | 401 | */ |
402 | - public static function printv( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) { |
|
402 | + public static function printv($var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false) { |
|
403 | 403 | $var_name = ! $var_name ? 'string' : $var_name; |
404 | 404 | $heading_tag = 'h'; |
405 | - $heading_tag .= is_int( $header ) ? $header : 5; |
|
406 | - $var_name = ucwords( str_replace( '$', '', $var_name ) ); |
|
407 | - $is_method = method_exists( $var_name, $var ); |
|
408 | - $var_name = ucwords( str_replace( '_', ' ', $var_name ) ); |
|
405 | + $heading_tag .= is_int($header) ? $header : 5; |
|
406 | + $var_name = ucwords(str_replace('$', '', $var_name)); |
|
407 | + $is_method = method_exists($var_name, $var); |
|
408 | + $var_name = ucwords(str_replace('_', ' ', $var_name)); |
|
409 | 409 | ob_start(); |
410 | - echo '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0;"><b>' . $var_name . '</b>'; |
|
410 | + echo '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0;"><b>'.$var_name.'</b>'; |
|
411 | 411 | echo $is_method |
412 | - ? '<span style="color:#999">::</span><span style="color:#E76700">' . $var . '()</span><br />' |
|
413 | - : '<span style="color:#999"> : </span><span style="color:#E76700">' . $var . '</span><br />'; |
|
414 | - echo '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file; |
|
415 | - echo '<br />line no: ' . $line . '</span>'; |
|
416 | - echo '</' . $heading_tag . '>'; |
|
412 | + ? '<span style="color:#999">::</span><span style="color:#E76700">'.$var.'()</span><br />' |
|
413 | + : '<span style="color:#999"> : </span><span style="color:#E76700">'.$var.'</span><br />'; |
|
414 | + echo '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file; |
|
415 | + echo '<br />line no: '.$line.'</span>'; |
|
416 | + echo '</'.$heading_tag.'>'; |
|
417 | 417 | $result = ob_get_clean(); |
418 | - if ( $die ) { |
|
419 | - die( $result ); |
|
418 | + if ($die) { |
|
419 | + die($result); |
|
420 | 420 | } else { |
421 | 421 | echo $result; |
422 | 422 | } |
@@ -435,35 +435,35 @@ discard block |
||
435 | 435 | * @param int $header |
436 | 436 | * @param bool $die |
437 | 437 | */ |
438 | - public static function printr( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) { |
|
439 | - $file = str_replace( rtrim( ABSPATH, '\\/' ), '', $file ); |
|
438 | + public static function printr($var, $var_name = false, $file = __FILE__, $line = __LINE__, $header = 5, $die = false) { |
|
439 | + $file = str_replace(rtrim(ABSPATH, '\\/'), '', $file); |
|
440 | 440 | //$print_r = false; |
441 | - if ( is_string( $var ) ) { |
|
442 | - EEH_Debug_Tools::printv( $var, $var_name, $file, $line, $header, $die ); |
|
441 | + if (is_string($var)) { |
|
442 | + EEH_Debug_Tools::printv($var, $var_name, $file, $line, $header, $die); |
|
443 | 443 | return; |
444 | - } else if ( is_object( $var ) ) { |
|
444 | + } else if (is_object($var)) { |
|
445 | 445 | $var_name = ! $var_name ? 'object' : $var_name; |
446 | 446 | //$print_r = true; |
447 | - } else if ( is_array( $var ) ) { |
|
447 | + } else if (is_array($var)) { |
|
448 | 448 | $var_name = ! $var_name ? 'array' : $var_name; |
449 | 449 | //$print_r = true; |
450 | - } else if ( is_numeric( $var ) ) { |
|
450 | + } else if (is_numeric($var)) { |
|
451 | 451 | $var_name = ! $var_name ? 'numeric' : $var_name; |
452 | - } else if ( is_null( $var ) ) { |
|
452 | + } else if (is_null($var)) { |
|
453 | 453 | $var_name = ! $var_name ? 'null' : $var_name; |
454 | 454 | } |
455 | 455 | $heading_tag = 'h'; |
456 | - $heading_tag .= is_int( $header ) ? $header : 5; |
|
457 | - $var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) ); |
|
456 | + $heading_tag .= is_int($header) ? $header : 5; |
|
457 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
458 | 458 | ob_start(); |
459 | - echo '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0;"><b>' . $var_name . '</b>'; |
|
459 | + echo '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0;"><b>'.$var_name.'</b>'; |
|
460 | 460 | echo '<span style="color:#999"> : </span><span style="color:#E76700">'; |
461 | - var_dump( $var ); |
|
462 | - echo '</span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file; |
|
463 | - echo '<br />line no: ' . $line . '</span></' . $heading_tag . '>'; |
|
461 | + var_dump($var); |
|
462 | + echo '</span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file; |
|
463 | + echo '<br />line no: '.$line.'</span></'.$heading_tag.'>'; |
|
464 | 464 | $result = ob_get_clean(); |
465 | - if ( $die ) { |
|
466 | - die( $result ); |
|
465 | + if ($die) { |
|
466 | + die($result); |
|
467 | 467 | } else { |
468 | 468 | echo $result; |
469 | 469 | } |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | * borrowed from Kint Debugger |
481 | 481 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
482 | 482 | */ |
483 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) { |
|
484 | - function dump_wp_query(){ |
|
483 | +if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
|
484 | + function dump_wp_query() { |
|
485 | 485 | global $wp_query; |
486 | 486 | d($wp_query); |
487 | 487 | } |
@@ -491,8 +491,8 @@ discard block |
||
491 | 491 | * borrowed from Kint Debugger |
492 | 492 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
493 | 493 | */ |
494 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) { |
|
495 | - function dump_wp(){ |
|
494 | +if (class_exists('Kint') && ! function_exists('dump_wp')) { |
|
495 | + function dump_wp() { |
|
496 | 496 | global $wp; |
497 | 497 | d($wp); |
498 | 498 | } |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | * borrowed from Kint Debugger |
503 | 503 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
504 | 504 | */ |
505 | -if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) { |
|
506 | - function dump_post(){ |
|
505 | +if (class_exists('Kint') && ! function_exists('dump_post')) { |
|
506 | + function dump_post() { |
|
507 | 507 | global $post; |
508 | 508 | d($post); |
509 | 509 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | <?php _e('As with most open source programs (and closed licensed programs), the possibility exists that you may find the occasional bug or discover that something is not working as expected. Please don\'t panic! We are here to help you.', 'event_espresso'); ?> |
10 | 10 | </p> |
11 | 11 | <p> |
12 | - <?php printf( __('If your problems are not urgent, please post in our %ssupport forums%s. If you need immediate help, please purchase a support token and you\'ll be able to schedule one-on-one time with a member of our team.', 'event_espresso'), '<a href="https://eventespresso.com/support/forums/" target="_blank">', '</a>' ); ?> |
|
12 | + <?php printf(__('If your problems are not urgent, please post in our %ssupport forums%s. If you need immediate help, please purchase a support token and you\'ll be able to schedule one-on-one time with a member of our team.', 'event_espresso'), '<a href="https://eventespresso.com/support/forums/" target="_blank">', '</a>'); ?> |
|
13 | 13 | </p> |
14 | 14 | <p class="ee-attention"> |
15 | 15 | <strong class="red_text"> |
@@ -30,6 +30,6 @@ discard block |
||
30 | 30 | <?php _e('A support token can be used towards receiving support for a single incident. Support is provided up to 30 minutes via phone call, instant message, or priority email support. Here are examples of how support tokens can be used: how-to questions, best practices questions, technical issues, advising on custom development.', 'event_espresso'); ?> |
31 | 31 | </p> |
32 | 32 | <p> |
33 | - <?php printf( __('You can learn more about support tokens and purchase one by %sclicking here%s.', 'event_espresso'),'<a href="https://eventespresso.com/product/premium-support-token/?utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=help_support_tab&utm_content=support_token" target="_blank">','</a>'); ?> |
|
33 | + <?php printf(__('You can learn more about support tokens and purchase one by %sclicking here%s.', 'event_espresso'), '<a href="https://eventespresso.com/product/premium-support-token/?utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=help_support_tab&utm_content=support_token" target="_blank">', '</a>'); ?> |
|
34 | 34 | </p> |
35 | 35 | </div> |
36 | 36 | \ No newline at end of file |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <div class="padding"> |
2 | 2 | <p> |
3 | - <?php _e('Displays a list of events based on a set of criteria on a WordPress page or post. Unless otherwise specified, events are sorted by start date.', 'event_espresso'); ?> <?php echo sprintf( __('For a full list of available shortcodes, please view the %sshortcode documentation%s on our website.', 'event_espresso'), '<a href="https://eventespresso.com/wiki/setup-event-espresso-arabica-theme/">', '</a>' ); ?> |
|
3 | + <?php _e('Displays a list of events based on a set of criteria on a WordPress page or post. Unless otherwise specified, events are sorted by start date.', 'event_espresso'); ?> <?php echo sprintf(__('For a full list of available shortcodes, please view the %sshortcode documentation%s on our website.', 'event_espresso'), '<a href="https://eventespresso.com/wiki/setup-event-espresso-arabica-theme/">', '</a>'); ?> |
|
4 | 4 | </p> |
5 | 5 | <ul> |
6 | 6 | <li><strong><?php _e('Show a list of all of your events', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS]</li> |
7 | 7 | <li><strong><?php _e('Set a custom title for the event list', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS title="My Super Event List"]</li> |
8 | 8 | <li><strong><?php _e('Limit (paginate) the number of events that are shown in the event list on a page or post', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS limit=5]</li> |
9 | 9 | <li><strong><?php _e('Add a custom CSS class to each event post/article', 'event_espresso'); ?></strong><br /> [ESPRESSO_EVENTS css_class=my-custom-class]</li> |
10 | - <li><strong><?php _e('Filter the event list by month and year', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS month="<?php echo date( 'F Y' ); ?>"]</li> |
|
10 | + <li><strong><?php _e('Filter the event list by month and year', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS month="<?php echo date('F Y'); ?>"]</li> |
|
11 | 11 | <li><strong><?php _e('Show expired events in the event list', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS show_expired=true]</li> |
12 | 12 | <li><strong><?php _e('Sorts the event list in ascending order', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS sort=ASC]</li> |
13 | 13 | <li><strong><?php _e('Sorts the event list in descending order', 'event_espresso'); ?></strong><br />[ESPRESSO_EVENTS sort=DESC]</li> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @author Mike Nelson |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEG_Mijireh extends EE_Offsite_Gateway{ |
|
11 | +class EEG_Mijireh extends EE_Offsite_Gateway { |
|
12 | 12 | |
13 | 13 | protected $_access_key; |
14 | 14 | |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | $primary_attendee = $primary_registrant->attendee(); |
38 | 38 | $items = array(); |
39 | 39 | //if we're are charging for the full amount, show the normal line items |
40 | - if( $this->_can_easily_itemize_transaction_for( $payment )){ |
|
40 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
41 | 41 | $total_line_item = $transaction->total_line_item(); |
42 | 42 | $tax_total = $total_line_item->get_total_tax(); |
43 | - foreach($total_line_item->get_items() as $line_item){ |
|
43 | + foreach ($total_line_item->get_items() as $line_item) { |
|
44 | 44 | $items[] = array( |
45 | 45 | 'name'=>apply_filters( |
46 | 46 | 'FHEE__EEG_Mijireh__set_redirection_info__full_amount_line_item_name', |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'quantity'=>$line_item->quantity() |
55 | 55 | ); |
56 | 56 | } |
57 | - }else{//its a partial payment |
|
57 | + } else {//its a partial payment |
|
58 | 58 | $tax_total = 0; |
59 | 59 | //partial payment, so just add 1 item |
60 | 60 | $items[] = array( |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | 'FHEE__EEG_Mijireh__set_redirection_info__partial_amount_line_item_name', |
63 | 63 | sprintf( |
64 | 64 | __("Payment of %s for %s", 'event_espresso'), |
65 | - $payment->get_pretty( 'PAY_amount', 'no_currency_code' ), |
|
65 | + $payment->get_pretty('PAY_amount', 'no_currency_code'), |
|
66 | 66 | $primary_registrant->event_name() |
67 | 67 | ), |
68 | 68 | $payment, |
@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | $order = array( |
77 | 77 | 'total'=>$this->format_currency($payment->amount()), |
78 | 78 | 'return_url'=>$return_url, |
79 | - 'items'=>$this->_prepare_for_mijireh( $items ), |
|
79 | + 'items'=>$this->_prepare_for_mijireh($items), |
|
80 | 80 | 'email'=>$primary_attendee->email(), |
81 | 81 | 'first_name'=>$primary_attendee->fname(), |
82 | 82 | 'last_name'=>$primary_attendee->lname(), |
83 | 83 | 'tax'=>$this->format_currency($tax_total), |
84 | 84 | 'partner_id'=>'ee'); |
85 | 85 | //setup address? |
86 | - if( $primary_attendee->address() && |
|
87 | - $primary_attendee->city() && |
|
88 | - $primary_attendee->state_ID() && |
|
89 | - $primary_attendee->country_ID() && |
|
90 | - $primary_attendee->zip() ){ |
|
86 | + if ($primary_attendee->address() && |
|
87 | + $primary_attendee->city() && |
|
88 | + $primary_attendee->state_ID() && |
|
89 | + $primary_attendee->country_ID() && |
|
90 | + $primary_attendee->zip()) { |
|
91 | 91 | $shipping_address = array( |
92 | 92 | 'first_name'=>$primary_attendee->fname(), |
93 | 93 | 'last_name'=>$primary_attendee->lname(), |
@@ -97,62 +97,62 @@ discard block |
||
97 | 97 | 'zip_code' => $primary_attendee->zip(), |
98 | 98 | 'country' => $primary_attendee->country_ID() |
99 | 99 | ); |
100 | - if( $primary_attendee->address2() ){ |
|
101 | - $shipping_address[ 'apt_suite' ] = $primary_attendee->address2(); |
|
100 | + if ($primary_attendee->address2()) { |
|
101 | + $shipping_address['apt_suite'] = $primary_attendee->address2(); |
|
102 | 102 | } |
103 | - if( $primary_attendee->phone() ){ |
|
104 | - $shipping_address[ 'phone' ] = $primary_attendee->phone(); |
|
103 | + if ($primary_attendee->phone()) { |
|
104 | + $shipping_address['phone'] = $primary_attendee->phone(); |
|
105 | 105 | } |
106 | - $order[ 'shipping_address' ] = $shipping_address; |
|
106 | + $order['shipping_address'] = $shipping_address; |
|
107 | 107 | } |
108 | - $order = apply_filters( 'FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant ); |
|
109 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this)) ); |
|
108 | + $order = apply_filters('FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant); |
|
109 | + do_action('AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this))); |
|
110 | 110 | $args = array( |
111 | 111 | 'headers' => array( |
112 | - 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
112 | + 'Authorization' => 'Basic '.base64_encode($this->_access_key.':'), |
|
113 | 113 | 'Accept'=>'application/json' |
114 | 114 | ), |
115 | 115 | 'body'=> json_encode($order) |
116 | 116 | ); |
117 | - $response = wp_remote_post( $this->_mijireh_api_orders_url, $args ); |
|
117 | + $response = wp_remote_post($this->_mijireh_api_orders_url, $args); |
|
118 | 118 | $problems_string = false; |
119 | - $this->log(array('get checkout url request_args' => $args, 'response' => $response ), $payment); |
|
120 | - if( ! $response instanceof WP_Error ){ |
|
119 | + $this->log(array('get checkout url request_args' => $args, 'response' => $response), $payment); |
|
120 | + if ( ! $response instanceof WP_Error) { |
|
121 | 121 | $response_body = json_decode($response['body']); |
122 | - if($response_body && isset($response_body->checkout_url)){ |
|
122 | + if ($response_body && isset($response_body->checkout_url)) { |
|
123 | 123 | $payment->set_redirect_url($response_body->checkout_url); |
124 | 124 | $payment->set_txn_id_chq_nmbr($response_body->order_number); |
125 | 125 | $payment->set_details($response['body']); |
126 | 126 | } else { |
127 | - if( is_array( $response_body ) || is_object( $response_body)){ |
|
128 | - $response_body_as_array = (array)$response_body; |
|
129 | - foreach($response_body_as_array as $problem_parameter => $problems){ |
|
130 | - $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems)); |
|
127 | + if (is_array($response_body) || is_object($response_body)) { |
|
128 | + $response_body_as_array = (array) $response_body; |
|
129 | + foreach ($response_body_as_array as $problem_parameter => $problems) { |
|
130 | + $problems_string .= sprintf(__('\nProblems with %s: %s', 'event_espresso'), $problem_parameter, implode(", ", $problems)); |
|
131 | 131 | } |
132 | - }else{ |
|
132 | + } else { |
|
133 | 133 | $problems_string = $response['body']; |
134 | 134 | } |
135 | - if( ! $problems_string ) { |
|
135 | + if ( ! $problems_string) { |
|
136 | 136 | //no message to show? wack |
137 | - if( isset( $response[ 'headers' ][ 'status' ] ) ){ |
|
138 | - $problems_string = $response[ 'headers' ][ 'status' ]; |
|
139 | - }else{ |
|
140 | - $problems_string = __( 'No response from Mijireh', 'event_espresso' ); |
|
137 | + if (isset($response['headers']['status'])) { |
|
138 | + $problems_string = $response['headers']['status']; |
|
139 | + } else { |
|
140 | + $problems_string = __('No response from Mijireh', 'event_espresso'); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
144 | - }else{ |
|
145 | - $problems_string = implode( ",", $response->get_error_messages() ); |
|
144 | + } else { |
|
145 | + $problems_string = implode(",", $response->get_error_messages()); |
|
146 | 146 | } |
147 | 147 | |
148 | - if( $problems_string ) { |
|
149 | - $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) ); |
|
150 | - $payment->set_details( $response ); |
|
151 | - $payment->set_redirect_url( null ); |
|
148 | + if ($problems_string) { |
|
149 | + $payment->set_gateway_response(sprintf(__('Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string)); |
|
150 | + $payment->set_details($response); |
|
151 | + $payment->set_redirect_url(null); |
|
152 | 152 | //even though the payment's status is failed at this point anyways, |
153 | 153 | //let's be explicit about it. The fact that the redirect url is null |
154 | 154 | //should be enough to client code that they can't redirect the user |
155 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
155 | + $payment->set_status($this->_pay_model->failed_status()); |
|
156 | 156 | } |
157 | 157 | return $payment; |
158 | 158 | } |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | * @param mixed $data |
166 | 166 | * @return mixed same type as $data |
167 | 167 | */ |
168 | - private function _prepare_for_mijireh( $data ){ |
|
169 | - if( is_array( $data ) ){ |
|
168 | + private function _prepare_for_mijireh($data) { |
|
169 | + if (is_array($data)) { |
|
170 | 170 | $prepared_data = array(); |
171 | - foreach($data as $key => $datum ){ |
|
172 | - $prepared_data[ $key ] = $this->_prepare_for_mijireh( $datum ); |
|
171 | + foreach ($data as $key => $datum) { |
|
172 | + $prepared_data[$key] = $this->_prepare_for_mijireh($datum); |
|
173 | 173 | } |
174 | 174 | return $prepared_data; |
175 | - }elseif(is_string( $data ) ){ |
|
176 | - return str_replace( '%', 'percent', $data ); |
|
177 | - }else{ |
|
175 | + }elseif (is_string($data)) { |
|
176 | + return str_replace('%', 'percent', $data); |
|
177 | + } else { |
|
178 | 178 | return $data; |
179 | 179 | } |
180 | 180 | } |
@@ -195,30 +195,30 @@ discard block |
||
195 | 195 | |
196 | 196 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : NULL; |
197 | 197 | |
198 | - if ( ! $payment instanceof EEI_Payment ){ |
|
199 | - throw new EE_Error( sprintf( __( "Could not find Mijireh payment for transaction %s", 'event_espresso' ), $transaction->ID() ) ); |
|
198 | + if ( ! $payment instanceof EEI_Payment) { |
|
199 | + throw new EE_Error(sprintf(__("Could not find Mijireh payment for transaction %s", 'event_espresso'), $transaction->ID())); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | $request_args = array( |
203 | 203 | 'headers' => array( |
204 | - 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
204 | + 'Authorization' => 'Basic '.base64_encode($this->_access_key.':'), |
|
205 | 205 | 'Accept'=>'application/json' |
206 | 206 | ) |
207 | 207 | ); |
208 | 208 | |
209 | 209 | $response = wp_remote_get( |
210 | - $this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(), |
|
210 | + $this->_mijireh_api_orders_url.'/'.$payment->txn_id_chq_nmbr(), |
|
211 | 211 | $request_args |
212 | 212 | ); |
213 | 213 | |
214 | 214 | $this->log( |
215 | - array( 'get payment status request_args' => $request_args, 'response' => $response ), |
|
215 | + array('get payment status request_args' => $request_args, 'response' => $response), |
|
216 | 216 | $payment |
217 | 217 | ); |
218 | 218 | // validate response |
219 | - $response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : ''; |
|
220 | - if( $response && $response_body ){ |
|
221 | - switch( $response_body->status ){ |
|
219 | + $response_body = isset($response['body']) ? json_decode($response['body']) : ''; |
|
220 | + if ($response && $response_body) { |
|
221 | + switch ($response_body->status) { |
|
222 | 222 | case 'paid': |
223 | 223 | $payment->set_status($this->_pay_model->approved_status()); |
224 | 224 | break; |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | } else { |
233 | - $payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) ); |
|
234 | - $payment->set_details( $response ); |
|
235 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
233 | + $payment->set_gateway_response(__('Response from Mijireh could not be understood.', 'event_espresso')); |
|
234 | + $payment->set_details($response); |
|
235 | + $payment->set_status($this->_pay_model->failed_status()); |
|
236 | 236 | } |
237 | 237 | // the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage |
238 | 238 | // $payment->set_status( $this->_pay_model->pending_status() ); |
@@ -115,45 +115,45 @@ |
||
115 | 115 | 'body'=> json_encode($order) |
116 | 116 | ); |
117 | 117 | $response = wp_remote_post( $this->_mijireh_api_orders_url, $args ); |
118 | - $problems_string = false; |
|
118 | + $problems_string = false; |
|
119 | 119 | $this->log(array('get checkout url request_args' => $args, 'response' => $response ), $payment); |
120 | 120 | if( ! $response instanceof WP_Error ){ |
121 | 121 | $response_body = json_decode($response['body']); |
122 | 122 | if($response_body && isset($response_body->checkout_url)){ |
123 | - $payment->set_redirect_url($response_body->checkout_url); |
|
124 | - $payment->set_txn_id_chq_nmbr($response_body->order_number); |
|
125 | - $payment->set_details($response['body']); |
|
123 | + $payment->set_redirect_url($response_body->checkout_url); |
|
124 | + $payment->set_txn_id_chq_nmbr($response_body->order_number); |
|
125 | + $payment->set_details($response['body']); |
|
126 | 126 | } else { |
127 | - if( is_array( $response_body ) || is_object( $response_body)){ |
|
128 | - $response_body_as_array = (array)$response_body; |
|
129 | - foreach($response_body_as_array as $problem_parameter => $problems){ |
|
130 | - $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems)); |
|
131 | - } |
|
132 | - }else{ |
|
133 | - $problems_string = $response['body']; |
|
134 | - } |
|
135 | - if( ! $problems_string ) { |
|
136 | - //no message to show? wack |
|
137 | - if( isset( $response[ 'headers' ][ 'status' ] ) ){ |
|
138 | - $problems_string = $response[ 'headers' ][ 'status' ]; |
|
139 | - }else{ |
|
140 | - $problems_string = __( 'No response from Mijireh', 'event_espresso' ); |
|
141 | - } |
|
142 | - } |
|
143 | - } |
|
127 | + if( is_array( $response_body ) || is_object( $response_body)){ |
|
128 | + $response_body_as_array = (array)$response_body; |
|
129 | + foreach($response_body_as_array as $problem_parameter => $problems){ |
|
130 | + $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems)); |
|
131 | + } |
|
132 | + }else{ |
|
133 | + $problems_string = $response['body']; |
|
134 | + } |
|
135 | + if( ! $problems_string ) { |
|
136 | + //no message to show? wack |
|
137 | + if( isset( $response[ 'headers' ][ 'status' ] ) ){ |
|
138 | + $problems_string = $response[ 'headers' ][ 'status' ]; |
|
139 | + }else{ |
|
140 | + $problems_string = __( 'No response from Mijireh', 'event_espresso' ); |
|
141 | + } |
|
142 | + } |
|
143 | + } |
|
144 | 144 | }else{ |
145 | - $problems_string = implode( ",", $response->get_error_messages() ); |
|
145 | + $problems_string = implode( ",", $response->get_error_messages() ); |
|
146 | 146 | } |
147 | 147 | |
148 | - if( $problems_string ) { |
|
149 | - $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) ); |
|
150 | - $payment->set_details( $response ); |
|
151 | - $payment->set_redirect_url( null ); |
|
152 | - //even though the payment's status is failed at this point anyways, |
|
153 | - //let's be explicit about it. The fact that the redirect url is null |
|
154 | - //should be enough to client code that they can't redirect the user |
|
155 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
156 | - } |
|
148 | + if( $problems_string ) { |
|
149 | + $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) ); |
|
150 | + $payment->set_details( $response ); |
|
151 | + $payment->set_redirect_url( null ); |
|
152 | + //even though the payment's status is failed at this point anyways, |
|
153 | + //let's be explicit about it. The fact that the redirect url is null |
|
154 | + //should be enough to client code that they can't redirect the user |
|
155 | + $payment->set_status( $this->_pay_model->failed_status() ); |
|
156 | + } |
|
157 | 157 | return $payment; |
158 | 158 | } |
159 | 159 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public static function instance() { |
80 | 80 | // check if class object is instantiated |
81 | - if ( ! self::$_instance instanceof EE_CPT_Strategy ) { |
|
81 | + if ( ! self::$_instance instanceof EE_CPT_Strategy) { |
|
82 | 82 | self::$_instance = new self(); |
83 | 83 | } |
84 | 84 | return self::$_instance; |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | // d( $this->_CPT_endpoints ); |
102 | 102 | // d( $this->_CPT_taxonomies ); |
103 | 103 | |
104 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 5 ); |
|
104 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 5); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | */ |
115 | 115 | private function _set_CPT_endpoints() { |
116 | 116 | $_CPT_endpoints = array(); |
117 | - if ( is_array( $this->_CPTs )) { |
|
118 | - foreach ( $this->_CPTs as $CPT_type => $CPT ) { |
|
119 | - $_CPT_endpoints [ $CPT['plural_slug'] ] = $CPT_type; |
|
117 | + if (is_array($this->_CPTs)) { |
|
118 | + foreach ($this->_CPTs as $CPT_type => $CPT) { |
|
119 | + $_CPT_endpoints [$CPT['plural_slug']] = $CPT_type; |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | return $_CPT_endpoints; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param WP_Query $WP_Query |
132 | 132 | * @return void |
133 | 133 | */ |
134 | - private function _set_EE_tags_on_WP_Query( WP_Query $WP_Query) { |
|
134 | + private function _set_EE_tags_on_WP_Query(WP_Query $WP_Query) { |
|
135 | 135 | $WP_Query->is_espresso_event_single = FALSE; |
136 | 136 | $WP_Query->is_espresso_event_archive = FALSE; |
137 | 137 | $WP_Query->is_espresso_event_taxonomy = FALSE; |
@@ -158,16 +158,16 @@ discard block |
||
158 | 158 | */ |
159 | 159 | private function _set_CPT_taxonomies() { |
160 | 160 | // check if taxonomies have already been set |
161 | - if ( empty( $this->_CPT_taxonomies )) { |
|
161 | + if (empty($this->_CPT_taxonomies)) { |
|
162 | 162 | // and that this CPT has taxonomies registered for it |
163 | - if ( isset( $this->CPT['args'] ) && isset( $this->CPT['args']['taxonomies'] )) { |
|
163 | + if (isset($this->CPT['args']) && isset($this->CPT['args']['taxonomies'])) { |
|
164 | 164 | // if so then grab them, but we want the taxonomy name as the key |
165 | - $taxonomies = array_flip( $this->CPT['args']['taxonomies'] ); |
|
165 | + $taxonomies = array_flip($this->CPT['args']['taxonomies']); |
|
166 | 166 | // then grab the list of ALL taxonomies |
167 | 167 | $all_taxonomies = EE_Register_CPTs::get_taxonomies(); |
168 | - foreach ( $taxonomies as $taxonomy => $details ) { |
|
168 | + foreach ($taxonomies as $taxonomy => $details) { |
|
169 | 169 | // add details to our taxonomies if they exist |
170 | - $taxonomies[ $taxonomy ] = isset( $all_taxonomies[ $taxonomy ] ) ? $all_taxonomies[ $taxonomy ] : NULL; |
|
170 | + $taxonomies[$taxonomy] = isset($all_taxonomies[$taxonomy]) ? $all_taxonomies[$taxonomy] : NULL; |
|
171 | 171 | } |
172 | 172 | $this->_CPT_taxonomies = $taxonomies; |
173 | 173 | } |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | * @return void |
193 | 193 | */ |
194 | 194 | private function _set_CPT_terms() { |
195 | - if ( empty( $this->_CPT_terms )) { |
|
195 | + if (empty($this->_CPT_terms)) { |
|
196 | 196 | $terms = EEM_Term::instance()->get_all_CPT_post_tags(); |
197 | - foreach ( $terms as $term ) { |
|
198 | - if ( $term instanceof EE_Term ) { |
|
199 | - $this->_CPT_terms[ $term->slug() ] = $term; |
|
197 | + foreach ($terms as $term) { |
|
198 | + if ($term instanceof EE_Term) { |
|
199 | + $this->_CPT_terms[$term->slug()] = $term; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
@@ -211,24 +211,24 @@ discard block |
||
211 | 211 | * @param $WP_Query |
212 | 212 | * @return void |
213 | 213 | */ |
214 | - private function _set_post_type_for_terms( WP_Query $WP_Query ) { |
|
214 | + private function _set_post_type_for_terms(WP_Query $WP_Query) { |
|
215 | 215 | // is a tag set ? |
216 | - if ( isset( $WP_Query->query['tag'] )) { |
|
216 | + if (isset($WP_Query->query['tag'])) { |
|
217 | 217 | // set post_tags |
218 | 218 | $this->_set_CPT_terms(); |
219 | 219 | // is this tag archive term in the list of terms used by our CPTs ? |
220 | - $term = isset ( $this->_CPT_terms[ $WP_Query->query['tag'] ] ) ? $this->_CPT_terms[ $WP_Query->query['tag'] ] : NULL; |
|
220 | + $term = isset ($this->_CPT_terms[$WP_Query->query['tag']]) ? $this->_CPT_terms[$WP_Query->query['tag']] : NULL; |
|
221 | 221 | // verify the term |
222 | - if ( $term instanceof EE_Term ) { |
|
223 | - $term->post_type = array_merge( array( 'post', 'page' ), (array)$term->post_type ); |
|
224 | - $term->post_type = apply_filters( 'FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term ); |
|
222 | + if ($term instanceof EE_Term) { |
|
223 | + $term->post_type = array_merge(array('post', 'page'), (array) $term->post_type); |
|
224 | + $term->post_type = apply_filters('FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term); |
|
225 | 225 | // if a post type is already set |
226 | - if ( isset( $WP_Query->query_vars['post_type'] )) { |
|
226 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
227 | 227 | // add to existing array |
228 | - $term->post_type = array_merge ( (array)$WP_Query->query_vars['post_type'], $term->post_type ); |
|
228 | + $term->post_type = array_merge((array) $WP_Query->query_vars['post_type'], $term->post_type); |
|
229 | 229 | } |
230 | 230 | // just set post_type to our CPT |
231 | - $WP_Query->set( 'post_type', $term->post_type ); |
|
231 | + $WP_Query->set('post_type', $term->post_type); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | } |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | * in order for is_archive() and is_single() methods to work properly. |
244 | 244 | * @return void |
245 | 245 | */ |
246 | - public function _possibly_set_ee_request_var(){ |
|
246 | + public function _possibly_set_ee_request_var() { |
|
247 | 247 | // check if ee action var has been set |
248 | - if ( ! EE_Registry::instance()->REQ->is_set( 'ee' )) { |
|
248 | + if ( ! EE_Registry::instance()->REQ->is_set('ee')) { |
|
249 | 249 | // check that route exists for CPT archive slug |
250 | - if ( is_archive() && EE_Config::get_route( $this->CPT['plural_slug'] )) { |
|
250 | + if (is_archive() && EE_Config::get_route($this->CPT['plural_slug'])) { |
|
251 | 251 | // ie: set "ee" to "events" |
252 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['plural_slug'] ); |
|
252 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['plural_slug']); |
|
253 | 253 | // or does it match a single page CPT like /event/ |
254 | - } else if ( is_single() && EE_Config::get_route( $this->CPT['singular_slug'] )) { |
|
254 | + } else if (is_single() && EE_Config::get_route($this->CPT['singular_slug'])) { |
|
255 | 255 | // ie: set "ee" to "event" |
256 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['singular_slug'] ); |
|
256 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['singular_slug']); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
@@ -267,11 +267,11 @@ discard block |
||
267 | 267 | * @param WP_Query $WP_Query |
268 | 268 | * @return void |
269 | 269 | */ |
270 | - public function _set_paging( $WP_Query ) { |
|
271 | - if ( $WP_Query->is_main_query() && apply_filters( 'FHEE__EE_CPT_Strategy___set_paging', TRUE )) { |
|
272 | - $page = ( get_query_var('page') ) ? get_query_var('page') : NULL; |
|
273 | - $paged = ( get_query_var('paged') ) ? get_query_var('paged') : $page; |
|
274 | - $WP_Query->set( 'paged', $paged ); |
|
270 | + public function _set_paging($WP_Query) { |
|
271 | + if ($WP_Query->is_main_query() && apply_filters('FHEE__EE_CPT_Strategy___set_paging', TRUE)) { |
|
272 | + $page = (get_query_var('page')) ? get_query_var('page') : NULL; |
|
273 | + $paged = (get_query_var('paged')) ? get_query_var('paged') : $page; |
|
274 | + $WP_Query->set('paged', $paged); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
@@ -288,35 +288,35 @@ discard block |
||
288 | 288 | * @param WP_Query $WP_Query |
289 | 289 | * @return void |
290 | 290 | */ |
291 | - public function pre_get_posts( $WP_Query ) { |
|
291 | + public function pre_get_posts($WP_Query) { |
|
292 | 292 | // check that post-type is set |
293 | - if ( ! $WP_Query instanceof WP_Query ) { |
|
293 | + if ( ! $WP_Query instanceof WP_Query) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // add our conditionals |
298 | - $this->_set_EE_tags_on_WP_Query( $WP_Query ); |
|
298 | + $this->_set_EE_tags_on_WP_Query($WP_Query); |
|
299 | 299 | // check for terms |
300 | - $this->_set_post_type_for_terms( $WP_Query ); |
|
300 | + $this->_set_post_type_for_terms($WP_Query); |
|
301 | 301 | // make sure paging is always set |
302 | - $this->_set_paging( $WP_Query ); |
|
302 | + $this->_set_paging($WP_Query); |
|
303 | 303 | |
304 | 304 | // is a taxonomy set ? |
305 | - if ( $WP_Query->is_tax ) { |
|
305 | + if ($WP_Query->is_tax) { |
|
306 | 306 | // loop thru our taxonomies |
307 | - foreach ( $this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details ) { |
|
307 | + foreach ($this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details) { |
|
308 | 308 | // check if one of our taxonomies is set as a query var |
309 | - if ( isset( $WP_Query->query[ $CPT_taxonomy ] )) { |
|
309 | + if (isset($WP_Query->query[$CPT_taxonomy])) { |
|
310 | 310 | // but which CPT does that correspond to??? hmmm... guess we gotta go looping |
311 | - foreach ( $this->_CPTs as $post_type => $CPT ) { |
|
311 | + foreach ($this->_CPTs as $post_type => $CPT) { |
|
312 | 312 | // verify our CPT has args, is public and has taxonomies set |
313 | - if ( isset( $CPT['args'] ) && $CPT['args']['public'] && ! empty( $CPT['args']['taxonomies'] )) { |
|
313 | + if (isset($CPT['args']) && $CPT['args']['public'] && ! empty($CPT['args']['taxonomies'])) { |
|
314 | 314 | // does the captured taxonomy belong to this CPT ? |
315 | - if ( in_array( $CPT_taxonomy, $CPT['args']['taxonomies'] )) { |
|
315 | + if (in_array($CPT_taxonomy, $CPT['args']['taxonomies'])) { |
|
316 | 316 | // if so, then add this CPT post_type to the current query's array of post_types' |
317 | - $WP_Query->query_vars['post_type'] = isset( $WP_Query->query_vars['post_type'] ) ? (array)$WP_Query->query_vars['post_type'] : array(); |
|
317 | + $WP_Query->query_vars['post_type'] = isset($WP_Query->query_vars['post_type']) ? (array) $WP_Query->query_vars['post_type'] : array(); |
|
318 | 318 | $WP_Query->query_vars['post_type'][] = $post_type; |
319 | - switch( $post_type ) { |
|
319 | + switch ($post_type) { |
|
320 | 320 | case 'espresso_events' : |
321 | 321 | $WP_Query->is_espresso_event_taxonomy = TRUE; |
322 | 322 | break; |
@@ -337,24 +337,24 @@ discard block |
||
337 | 337 | // d( $CPT_taxonomy ); |
338 | 338 | // d( $WP_Query ); |
339 | 339 | |
340 | - if ( isset( $WP_Query->query_vars['post_type'] )) { |
|
340 | + if (isset($WP_Query->query_vars['post_type'])) { |
|
341 | 341 | // loop thru post_types as array |
342 | - foreach ( (array)$WP_Query->query_vars['post_type'] as $post_type ) { |
|
342 | + foreach ((array) $WP_Query->query_vars['post_type'] as $post_type) { |
|
343 | 343 | |
344 | 344 | // is current query for an EE CPT ? |
345 | - if ( isset( $this->_CPTs[ $post_type ] )) { |
|
345 | + if (isset($this->_CPTs[$post_type])) { |
|
346 | 346 | // is EE on or off ? |
347 | - if ( EE_Maintenance_Mode::instance()->level() ) { |
|
347 | + if (EE_Maintenance_Mode::instance()->level()) { |
|
348 | 348 | // reroute CPT template view to maintenance_mode.template.php |
349 | - if( ! has_filter( 'template_include',array( 'EE_Maintenance_Mode', 'template_include' ))){ |
|
350 | - add_filter( 'template_include', array( 'EE_Maintenance_Mode', 'template_include' ), 99999 ); |
|
349 | + if ( ! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) { |
|
350 | + add_filter('template_include', array('EE_Maintenance_Mode', 'template_include'), 99999); |
|
351 | 351 | } |
352 | 352 | return; |
353 | 353 | } |
354 | 354 | // load EE_Request_Handler (this was added as a result of https://events.codebasehq.com/projects/event-espresso/tickets/9037 |
355 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
355 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
356 | 356 | // grab details for the CPT the current query is for |
357 | - $this->CPT = $this->_CPTs[ $post_type ]; |
|
357 | + $this->CPT = $this->_CPTs[$post_type]; |
|
358 | 358 | // set post type |
359 | 359 | $this->CPT['post_type'] = $post_type; |
360 | 360 | // set taxonomies |
@@ -362,27 +362,27 @@ discard block |
||
362 | 362 | // the post or category or term that is triggering EE |
363 | 363 | $this->CPT['espresso_page'] = EE_Registry::instance()->REQ->is_espresso_page(); |
364 | 364 | // requested post name |
365 | - $this->CPT['post_name'] = EE_Registry::instance()->REQ->get( 'post_name' ); |
|
365 | + $this->CPT['post_name'] = EE_Registry::instance()->REQ->get('post_name'); |
|
366 | 366 | //d( $this->CPT ); |
367 | 367 | // add support for viewing 'private', 'draft', or 'pending' posts |
368 | - if ( is_user_logged_in() && isset( $WP_Query->query_vars['p'] ) && $WP_Query->query_vars['p'] != 0 && current_user_can( 'edit_post', $WP_Query->query_vars['p'] )) { |
|
368 | + if (is_user_logged_in() && isset($WP_Query->query_vars['p']) && $WP_Query->query_vars['p'] != 0 && current_user_can('edit_post', $WP_Query->query_vars['p'])) { |
|
369 | 369 | // we can just inject directly into the WP_Query object |
370 | - $WP_Query->query['post_status'] = array( 'publish', 'private', 'draft', 'pending' ); |
|
370 | + $WP_Query->query['post_status'] = array('publish', 'private', 'draft', 'pending'); |
|
371 | 371 | // now set the main 'ee' request var so that the appropriate module can load the appropriate template(s) |
372 | - EE_Registry::instance()->REQ->set( 'ee', $this->CPT['singular_slug'] ); |
|
372 | + EE_Registry::instance()->REQ->set('ee', $this->CPT['singular_slug']); |
|
373 | 373 | } |
374 | 374 | $this->_possibly_set_ee_request_var(); |
375 | 375 | // convert post_type to model name |
376 | - $model_name = str_replace( 'EE_', '', $this->CPT['class_name'] ); |
|
376 | + $model_name = str_replace('EE_', '', $this->CPT['class_name']); |
|
377 | 377 | // get CPT table data via CPT Model |
378 | - $this->CPT_model = EE_Registry::instance()->load_model( $model_name ); |
|
378 | + $this->CPT_model = EE_Registry::instance()->load_model($model_name); |
|
379 | 379 | $this->CPT['tables'] = $this->CPT_model->get_tables(); |
380 | 380 | // is there a Meta Table for this CPT? |
381 | - $this->CPT['meta_table'] = isset( $this->CPT['tables'][ $model_name . '_Meta' ] ) ? $this->CPT['tables'][ $model_name . '_Meta' ] : FALSE; |
|
381 | + $this->CPT['meta_table'] = isset($this->CPT['tables'][$model_name.'_Meta']) ? $this->CPT['tables'][$model_name.'_Meta'] : FALSE; |
|
382 | 382 | // creates classname like: CPT_Event_Strategy |
383 | - $CPT_Strategy_class_name = 'CPT_' . $model_name . '_Strategy'; |
|
383 | + $CPT_Strategy_class_name = 'CPT_'.$model_name.'_Strategy'; |
|
384 | 384 | // load and instantiate |
385 | - $CPT_Strategy = EE_Registry::instance()->load_core ( $CPT_Strategy_class_name, array( 'WP_Query' => $WP_Query, 'CPT' => $this->CPT )); |
|
385 | + $CPT_Strategy = EE_Registry::instance()->load_core($CPT_Strategy_class_name, array('WP_Query' => $WP_Query, 'CPT' => $this->CPT)); |
|
386 | 386 | |
387 | 387 | // !!!!!!!!!! IMPORTANT !!!!!!!!!!!! |
388 | 388 | // here's the list of available filters in the WP_Query object |
@@ -394,13 +394,13 @@ discard block |
||
394 | 394 | // 'post_limits' |
395 | 395 | // 'posts_fields' |
396 | 396 | // 'posts_join' |
397 | - add_filter( 'posts_fields', array( $this, 'posts_fields' )); |
|
398 | - add_filter( 'posts_join', array( $this, 'posts_join' )); |
|
399 | - add_filter( 'get_' . $this->CPT['post_type'] . '_metadata', array( $CPT_Strategy, 'get_EE_post_type_metadata' ), 1, 4 ); |
|
400 | - add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 1 ); |
|
401 | - add_filter( 'get_edit_post_link', array( $this, 'get_edit_post_link' ), 10, 2 ); |
|
397 | + add_filter('posts_fields', array($this, 'posts_fields')); |
|
398 | + add_filter('posts_join', array($this, 'posts_join')); |
|
399 | + add_filter('get_'.$this->CPT['post_type'].'_metadata', array($CPT_Strategy, 'get_EE_post_type_metadata'), 1, 4); |
|
400 | + add_filter('the_posts', array($this, 'the_posts'), 1, 1); |
|
401 | + add_filter('get_edit_post_link', array($this, 'get_edit_post_link'), 10, 2); |
|
402 | 402 | |
403 | - $this->_do_template_filters( $WP_Query ); |
|
403 | + $this->_do_template_filters($WP_Query); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | } |
@@ -415,13 +415,13 @@ discard block |
||
415 | 415 | * @param $SQL |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - public function posts_fields( $SQL ) { |
|
418 | + public function posts_fields($SQL) { |
|
419 | 419 | // does this CPT have a meta table ? |
420 | - if ( ! empty( $this->CPT['meta_table'] )) { |
|
420 | + if ( ! empty($this->CPT['meta_table'])) { |
|
421 | 421 | // adds something like ", wp_esp_event_meta.* " to WP Query SELECT statement |
422 | - $SQL .= ', ' . $this->CPT['meta_table']->get_table_name() . '.* ' ; |
|
422 | + $SQL .= ', '.$this->CPT['meta_table']->get_table_name().'.* '; |
|
423 | 423 | } |
424 | - remove_filter( 'posts_fields', array( $this, 'posts_fields' )); |
|
424 | + remove_filter('posts_fields', array($this, 'posts_fields')); |
|
425 | 425 | return $SQL; |
426 | 426 | } |
427 | 427 | |
@@ -434,14 +434,14 @@ discard block |
||
434 | 434 | * @param $SQL |
435 | 435 | * @return string |
436 | 436 | */ |
437 | - public function posts_join( $SQL ) { |
|
437 | + public function posts_join($SQL) { |
|
438 | 438 | // does this CPT have a meta table ? |
439 | - if ( ! empty( $this->CPT['meta_table'] )) { |
|
439 | + if ( ! empty($this->CPT['meta_table'])) { |
|
440 | 440 | global $wpdb; |
441 | 441 | // adds something like " LEFT JOIN wp_esp_event_meta ON ( wp_esp_event_meta.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement |
442 | - $SQL .= ' LEFT JOIN ' . $this->CPT['meta_table']->get_table_name() . ' ON ( ' . $this->CPT['meta_table']->get_table_name() . '.' . $this->CPT['meta_table']->get_fk_on_table() . ' = ' . $wpdb->posts . '.ID ) '; |
|
442 | + $SQL .= ' LEFT JOIN '.$this->CPT['meta_table']->get_table_name().' ON ( '.$this->CPT['meta_table']->get_table_name().'.'.$this->CPT['meta_table']->get_fk_on_table().' = '.$wpdb->posts.'.ID ) '; |
|
443 | 443 | } |
444 | - remove_filter( 'posts_join', array( $this, 'posts_join' )); |
|
444 | + remove_filter('posts_join', array($this, 'posts_join')); |
|
445 | 445 | return $SQL; |
446 | 446 | } |
447 | 447 | |
@@ -454,18 +454,18 @@ discard block |
||
454 | 454 | * @param \WP_Post[] $posts |
455 | 455 | * @return \WP_Post[] |
456 | 456 | */ |
457 | - public function the_posts( $posts ) { |
|
457 | + public function the_posts($posts) { |
|
458 | 458 | // d( $posts ); |
459 | 459 | $CPT_class = $this->CPT['class_name']; |
460 | 460 | // loop thru posts |
461 | - if ( is_array( $posts )) { |
|
462 | - foreach( $posts as $key => $post ) { |
|
463 | - if ( isset( $this->_CPTs[ $post->post_type ] )) { |
|
464 | - $post->{$CPT_class} = $this->CPT_model->instantiate_class_from_post_object( $post ); |
|
461 | + if (is_array($posts)) { |
|
462 | + foreach ($posts as $key => $post) { |
|
463 | + if (isset($this->_CPTs[$post->post_type])) { |
|
464 | + $post->{$CPT_class} = $this->CPT_model->instantiate_class_from_post_object($post); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | } |
468 | - remove_filter( 'the_posts', array( $this, 'the_posts' ), 1 ); |
|
468 | + remove_filter('the_posts', array($this, 'the_posts'), 1); |
|
469 | 469 | return $posts; |
470 | 470 | } |
471 | 471 | |
@@ -476,17 +476,17 @@ discard block |
||
476 | 476 | * @param $ID |
477 | 477 | * @return string |
478 | 478 | */ |
479 | - function get_edit_post_link( $url, $ID ) { |
|
479 | + function get_edit_post_link($url, $ID) { |
|
480 | 480 | //need to make sure we only edit links if our cpt |
481 | 481 | global $post; |
482 | - if ( ! isset( $this->_CPTs[ $post->post_type ] )) { |
|
482 | + if ( ! isset($this->_CPTs[$post->post_type])) { |
|
483 | 483 | return $url; |
484 | 484 | } |
485 | 485 | //k made it here so all is good. |
486 | 486 | $scheme = is_ssl() ? 'https' : 'http'; |
487 | - $url = get_admin_url( EE_Config::instance()->core->current_blog_id, 'admin.php', $scheme ); |
|
487 | + $url = get_admin_url(EE_Config::instance()->core->current_blog_id, 'admin.php', $scheme); |
|
488 | 488 | // http://example.com/wp-admin/admin.php?page=espresso_events&action=edit&post=205&edit_nonce=0d403530d6 |
489 | - return wp_nonce_url( add_query_arg( array( 'page' => $this->CPT['post_type'], 'post' =>$ID, 'action' =>'edit' ), $url ), 'edit', 'edit_nonce' ); |
|
489 | + return wp_nonce_url(add_query_arg(array('page' => $this->CPT['post_type'], 'post' =>$ID, 'action' =>'edit'), $url), 'edit', 'edit_nonce'); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | |
@@ -500,11 +500,11 @@ discard block |
||
500 | 500 | * @param WP_Query $WP_Query |
501 | 501 | * @return void |
502 | 502 | */ |
503 | - protected function _do_template_filters( WP_Query $WP_Query ) { |
|
503 | + protected function _do_template_filters(WP_Query $WP_Query) { |
|
504 | 504 | // if it's the main query and requested cpt supports page_templates, |
505 | - if ( $WP_Query->is_main_query() && ! empty( $this->CPT['args']['page_templates'] ) ) { |
|
505 | + if ($WP_Query->is_main_query() && ! empty($this->CPT['args']['page_templates'])) { |
|
506 | 506 | // then let's hook into the appropriate query_template hook |
507 | - add_filter( 'single_template', array( $this, 'single_cpt_template' ) ); |
|
507 | + add_filter('single_template', array($this, 'single_cpt_template')); |
|
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
@@ -518,17 +518,17 @@ discard block |
||
518 | 518 | * @param string $current_template Existing default template path derived for this page call. |
519 | 519 | * @return string the path to the full template file. |
520 | 520 | */ |
521 | - public function single_cpt_template( $current_template ) { |
|
521 | + public function single_cpt_template($current_template) { |
|
522 | 522 | $object = get_queried_object(); |
523 | 523 | //does this called object HAVE a page template set that is something other than the default. |
524 | - $template = get_post_meta( $object->ID, '_wp_page_template', true ); |
|
524 | + $template = get_post_meta($object->ID, '_wp_page_template', true); |
|
525 | 525 | |
526 | 526 | //exit early if default or not set or invalid path (accounts for theme changes) |
527 | - if ( $template == 'default' || empty( $template ) || ! is_readable( get_stylesheet_directory() . '/' . $template ) ) { |
|
527 | + if ($template == 'default' || empty($template) || ! is_readable(get_stylesheet_directory().'/'.$template)) { |
|
528 | 528 | return $current_template; |
529 | 529 | } |
530 | 530 | //made it here so we SHOULD be able to just locate the template and then return it. |
531 | - $template = locate_template( array($template) ); |
|
531 | + $template = locate_template(array($template)); |
|
532 | 532 | |
533 | 533 | return $template; |
534 | 534 | } |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | * @param array $arguments |
577 | 577 | * @return \EE_CPT_Default_Strategy |
578 | 578 | */ |
579 | - public function __construct( $arguments = array() ) { |
|
580 | - $this->CPT = isset( $arguments['CPT'] ) ? $arguments['CPT'] : NULL; |
|
581 | - $WP_Query = isset( $arguments['WP_Query'] ) ? $arguments['WP_Query'] : NULL; |
|
579 | + public function __construct($arguments = array()) { |
|
580 | + $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : NULL; |
|
581 | + $WP_Query = isset($arguments['WP_Query']) ? $arguments['WP_Query'] : NULL; |
|
582 | 582 | //EEH_Debug_Tools::printr( $this->CPT, '$this->CPT <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
583 | 583 | // add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ), 999 ); |
584 | 584 | // add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 ); |
@@ -593,9 +593,9 @@ discard block |
||
593 | 593 | * @param \WP_Query $WP_Query |
594 | 594 | * @return \WP_Query |
595 | 595 | */ |
596 | - public function pre_get_posts( WP_Query $WP_Query ) { |
|
596 | + public function pre_get_posts(WP_Query $WP_Query) { |
|
597 | 597 | //EEH_Debug_Tools::printr( $WP_Query, '$WP_Query <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
598 | - if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive() ) { |
|
598 | + if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
599 | 599 | return $WP_Query; |
600 | 600 | } |
601 | 601 | // $WP_Query->set( 'post_type', array( $this->CPT['post_type'] )); |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | * @param \WP_Query $WP_Query |
614 | 614 | * @return \WP_Post[] |
615 | 615 | */ |
616 | - public function the_posts( $posts, WP_Query $WP_Query ) { |
|
616 | + public function the_posts($posts, WP_Query $WP_Query) { |
|
617 | 617 | return $posts; |
618 | 618 | } |
619 | 619 | |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | * @param string $single |
630 | 630 | * @return mixed |
631 | 631 | */ |
632 | - public function get_EE_post_type_metadata( $meta_value = NULL, $post_id, $meta_key, $single ) { |
|
632 | + public function get_EE_post_type_metadata($meta_value = NULL, $post_id, $meta_key, $single) { |
|
633 | 633 | return $meta_value; |
634 | 634 | } |
635 | 635 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param WP $WP |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - public abstract function run( WP $WP ); |
|
45 | + public abstract function run(WP $WP); |
|
46 | 46 | |
47 | 47 | |
48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param array $attributes |
55 | 55 | * @return mixed |
56 | 56 | */ |
57 | - public abstract function process_shortcode( $attributes = array() ); |
|
57 | + public abstract function process_shortcode($attributes = array()); |
|
58 | 58 | |
59 | 59 | |
60 | 60 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * @param string $shortcode_class |
66 | 66 | * @return \EES_Shortcode |
67 | 67 | */ |
68 | - final public static function instance( $shortcode_class = NULL ) { |
|
69 | - $shortcode_class = ! empty( $shortcode_class ) ? $shortcode_class : get_called_class(); |
|
70 | - if ( $shortcode_class == 'EES_Shortcode' || empty( $shortcode_class )) { |
|
68 | + final public static function instance($shortcode_class = NULL) { |
|
69 | + $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
70 | + if ($shortcode_class == 'EES_Shortcode' || empty($shortcode_class)) { |
|
71 | 71 | return NULL; |
72 | 72 | } |
73 | - $shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class )); |
|
74 | - $shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} ) ? EE_Registry::instance()->shortcodes->{$shortcode} : NULL; |
|
73 | + $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
74 | + $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode} ) ? EE_Registry::instance()->shortcodes->{$shortcode} : NULL; |
|
75 | 75 | return $shortcode_obj instanceof $shortcode_class || $shortcode_class == 'self' ? $shortcode_obj : new $shortcode_class(); |
76 | 76 | } |
77 | 77 | |
@@ -86,20 +86,20 @@ discard block |
||
86 | 86 | * @param $attributes |
87 | 87 | * @return mixed |
88 | 88 | */ |
89 | - final public static function fallback_shortcode_processor( $attributes ) { |
|
89 | + final public static function fallback_shortcode_processor($attributes) { |
|
90 | 90 | // what shortcode was actually parsed ? |
91 | 91 | $shortcode_class = get_called_class(); |
92 | 92 | // notify rest of system that fallback processor was triggered |
93 | - add_filter( 'FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true' ); |
|
93 | + add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true'); |
|
94 | 94 | // get instance of actual shortcode |
95 | - $shortcode_obj = self::instance( $shortcode_class ); |
|
95 | + $shortcode_obj = self::instance($shortcode_class); |
|
96 | 96 | // verify class |
97 | - if ( $shortcode_obj instanceof EES_Shortcode ) { |
|
97 | + if ($shortcode_obj instanceof EES_Shortcode) { |
|
98 | 98 | global $wp; |
99 | - $shortcode_obj->run( $wp ); |
|
99 | + $shortcode_obj->run($wp); |
|
100 | 100 | // set attributes and run the shortcode |
101 | - $shortcode_obj->_attributes = (array)$attributes; |
|
102 | - return $shortcode_obj->process_shortcode( $shortcode_obj->_attributes ); |
|
101 | + $shortcode_obj->_attributes = (array) $attributes; |
|
102 | + return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
103 | 103 | } else { |
104 | 104 | return NULL; |
105 | 105 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param $attributes |
116 | 116 | * @return string |
117 | 117 | */ |
118 | - final public static function invalid_shortcode_processor( $attributes ) { |
|
118 | + final public static function invalid_shortcode_processor($attributes) { |
|
119 | 119 | return ''; |
120 | 120 | } |
121 | 121 | |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | */ |
130 | 130 | final public function __construct() { |
131 | 131 | // get classname, remove EES_prefix, and convert to UPPERCASE |
132 | - $shortcode = strtoupper( str_replace( 'EES_', '', get_class( $this ))); |
|
132 | + $shortcode = strtoupper(str_replace('EES_', '', get_class($this))); |
|
133 | 133 | // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
134 | - add_shortcode( $shortcode, array( $this, 'process_shortcode' )); |
|
134 | + add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
135 | 135 | // make sure system knows this is an EE page |
136 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
136 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | 60 | // check if class object is instantiated, and instantiated properly |
61 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Network_Config )) { |
|
61 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Network_Config)) { |
|
62 | 62 | self::$_instance = new self(); |
63 | 63 | } |
64 | 64 | return self::$_instance; |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | * @return void |
75 | 75 | */ |
76 | 76 | private function __construct() { |
77 | - do_action( 'AHEE__EE_Network_Config__construct__begin',$this ); |
|
77 | + do_action('AHEE__EE_Network_Config__construct__begin', $this); |
|
78 | 78 | //set defaults |
79 | - $this->core = apply_filters( 'FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config() ); |
|
79 | + $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config()); |
|
80 | 80 | $this->addons = array(); |
81 | 81 | |
82 | 82 | $this->_load_config(); |
83 | 83 | |
84 | 84 | // construct__end hook |
85 | - do_action( 'AHEE__EE_Network_Config__construct__end',$this ); |
|
85 | + do_action('AHEE__EE_Network_Config__construct__end', $this); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | */ |
96 | 96 | private function _load_config() { |
97 | 97 | $config = $this->get_config(); |
98 | - foreach ( $config as $prop => $settings ) { |
|
99 | - $prop_class = is_object( $settings ) ? get_class( $this->{$prop} ) : FALSE; |
|
100 | - if ( ! empty( $settings ) && ( ! $prop_class || ( $settings instanceof $prop_class ))) { |
|
98 | + foreach ($config as $prop => $settings) { |
|
99 | + $prop_class = is_object($settings) ? get_class($this->{$prop} ) : FALSE; |
|
100 | + if ( ! empty($settings) && ( ! $prop_class || ($settings instanceof $prop_class))) { |
|
101 | 101 | $this->{$prop} = $settings; |
102 | 102 | } |
103 | 103 | } |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function get_config() { |
116 | 116 | // grab network configuration |
117 | - $CFG = get_site_option( 'ee_network_config', array() ); |
|
118 | - $CFG = apply_filters( 'FHEE__EE_Network_Config__get_config__CFG', $CFG ); |
|
117 | + $CFG = get_site_option('ee_network_config', array()); |
|
118 | + $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG); |
|
119 | 119 | return $CFG; |
120 | 120 | } |
121 | 121 | |
@@ -127,24 +127,24 @@ discard block |
||
127 | 127 | * @access public |
128 | 128 | * @return boolean success |
129 | 129 | */ |
130 | - public function update_config( $add_success = FALSE, $add_error = TRUE ) { |
|
131 | - do_action( 'AHEE__EE_Network_Config__update_config__begin',$this ); |
|
130 | + public function update_config($add_success = FALSE, $add_error = TRUE) { |
|
131 | + do_action('AHEE__EE_Network_Config__update_config__begin', $this); |
|
132 | 132 | // compare existing settings with what's already saved' |
133 | 133 | $saved_config = $this->get_config(); |
134 | 134 | // update |
135 | - $saved = $saved_config == $this ? TRUE : update_site_option( 'ee_network_config', $this ); |
|
136 | - do_action( 'AHEE__EE_Network_Config__update_config__end', $this, $saved ); |
|
135 | + $saved = $saved_config == $this ? TRUE : update_site_option('ee_network_config', $this); |
|
136 | + do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved); |
|
137 | 137 | // if config remains the same or was updated successfully |
138 | - if ( $saved ) { |
|
139 | - if ( $add_success ) { |
|
140 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso' ) : __( 'Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso' ); |
|
141 | - EE_Error::add_success( $msg ); |
|
138 | + if ($saved) { |
|
139 | + if ($add_success) { |
|
140 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso') : __('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso'); |
|
141 | + EE_Error::add_success($msg); |
|
142 | 142 | } |
143 | 143 | return TRUE; |
144 | 144 | } else { |
145 | - if ( $add_error ) { |
|
146 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings were not updated.', 'event_espresso' ) : __( 'Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso' ); |
|
147 | - EE_Error::add_error( $msg , __FILE__, __FUNCTION__, __LINE__ ); |
|
145 | + if ($add_error) { |
|
146 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings were not updated.', 'event_espresso') : __('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso'); |
|
147 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
148 | 148 | } |
149 | 149 | return FALSE; |
150 | 150 | } |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | * @return array |
159 | 159 | */ |
160 | 160 | public function __sleep() { |
161 | - return apply_filters( 'FHEE__EE_Network_Config__sleep',array( |
|
161 | + return apply_filters('FHEE__EE_Network_Config__sleep', array( |
|
162 | 162 | 'core', |
163 | - ) ); |
|
163 | + )); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | } //end EE_Network_Config. |
@@ -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( |
@@ -465,61 +465,61 @@ discard block |
||
465 | 465 | 'EE_Capabilities' => 'CAP' |
466 | 466 | ); |
467 | 467 | |
468 | - $class_abbreviation = isset( $class_abbreviations[ $class_name ] ) |
|
469 | - ? $class_abbreviations[ $class_name ] |
|
468 | + $class_abbreviation = isset($class_abbreviations[$class_name]) |
|
469 | + ? $class_abbreviations[$class_name] |
|
470 | 470 | : ''; |
471 | 471 | // check if class has already been loaded, and return it if it has been |
472 | - if ( $class_abbreviation !== '' && ! is_null( $this->{$class_abbreviation} ) |
|
472 | + if ($class_abbreviation !== '' && ! is_null($this->{$class_abbreviation} ) |
|
473 | 473 | ) { |
474 | 474 | return $this->{$class_abbreviation}; |
475 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
475 | + } else if (isset ($this->{$class_name} )) { |
|
476 | 476 | return $this->{$class_name}; |
477 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
477 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
478 | 478 | return $this->LIB->{$class_name}; |
479 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
479 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
480 | 480 | return $this->addons->{$class_name}; |
481 | 481 | } |
482 | 482 | |
483 | 483 | // assume all paths lead nowhere |
484 | 484 | $path = FALSE; |
485 | 485 | // make sure $file_paths is an array |
486 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
486 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
487 | 487 | // cycle thru paths |
488 | - foreach ( $file_paths as $key => $file_path ) { |
|
488 | + foreach ($file_paths as $key => $file_path) { |
|
489 | 489 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
490 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
490 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
491 | 491 | // prep file type |
492 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
492 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
493 | 493 | // build full file path |
494 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
494 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
495 | 495 | //does the file exist and can be read ? |
496 | - if ( is_readable( $file_paths[ $key ] )) { |
|
497 | - $path = $file_paths[ $key ]; |
|
496 | + if (is_readable($file_paths[$key])) { |
|
497 | + $path = $file_paths[$key]; |
|
498 | 498 | break; |
499 | 499 | } |
500 | 500 | } |
501 | 501 | // don't give up! you gotta... |
502 | 502 | try { |
503 | 503 | //does the file exist and can it be read ? |
504 | - if ( ! $path ) { |
|
504 | + if ( ! $path) { |
|
505 | 505 | // so sorry, can't find the file |
506 | - throw new EE_Error ( |
|
507 | - sprintf ( |
|
508 | - __('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'), |
|
509 | - trim( $type, '.' ), |
|
506 | + throw new EE_Error( |
|
507 | + sprintf( |
|
508 | + __('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'), |
|
509 | + trim($type, '.'), |
|
510 | 510 | $class_name, |
511 | - '<br />' . implode( ',<br />', $file_paths ) |
|
511 | + '<br />'.implode(',<br />', $file_paths) |
|
512 | 512 | ) |
513 | 513 | ); |
514 | 514 | } |
515 | 515 | // get the file |
516 | - require_once( $path ); |
|
516 | + require_once($path); |
|
517 | 517 | // if the class isn't already declared somewhere |
518 | - if ( class_exists( $class_name, FALSE ) === FALSE ) { |
|
518 | + if (class_exists($class_name, FALSE) === FALSE) { |
|
519 | 519 | // so sorry, not a class |
520 | 520 | throw new EE_Error( |
521 | 521 | sprintf( |
522 | - __('The %s file %s does not appear to contain the %s Class.','event_espresso'), |
|
522 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
523 | 523 | $type, |
524 | 524 | $path, |
525 | 525 | $class_name |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | ); |
528 | 528 | } |
529 | 529 | |
530 | - } catch ( EE_Error $e ) { |
|
530 | + } catch (EE_Error $e) { |
|
531 | 531 | $e->get_error(); |
532 | 532 | } |
533 | 533 | |
@@ -535,38 +535,38 @@ discard block |
||
535 | 535 | // don't give up! you gotta... |
536 | 536 | try { |
537 | 537 | // create reflection |
538 | - $reflector = new ReflectionClass( $class_name ); |
|
538 | + $reflector = new ReflectionClass($class_name); |
|
539 | 539 | // instantiate the class and add to the LIB array for tracking |
540 | 540 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
541 | - if ( $reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only ) { |
|
541 | + if ($reflector->getConstructor() === NULL || $reflector->isAbstract() || $load_only) { |
|
542 | 542 | // $instantiation_mode = 0; |
543 | 543 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
544 | 544 | return TRUE; |
545 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
545 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
546 | 546 | // $instantiation_mode = 1; |
547 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
548 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
547 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
548 | + } else if (method_exists($class_name, 'new_instance')) { |
|
549 | 549 | // $instantiation_mode = 2; |
550 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
551 | - } else if ( method_exists( $class_name, 'instance' )) { |
|
550 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
551 | + } else if (method_exists($class_name, 'instance')) { |
|
552 | 552 | // $instantiation_mode = 3; |
553 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
554 | - } else if ( $reflector->isInstantiable() ) { |
|
553 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
554 | + } else if ($reflector->isInstantiable()) { |
|
555 | 555 | // $instantiation_mode = 4; |
556 | - $class_obj = $reflector->newInstance( $arguments ); |
|
557 | - } else if ( ! $load_only ) { |
|
556 | + $class_obj = $reflector->newInstance($arguments); |
|
557 | + } else if ( ! $load_only) { |
|
558 | 558 | // heh ? something's not right ! |
559 | 559 | // $instantiation_mode = 5; |
560 | 560 | throw new EE_Error( |
561 | 561 | sprintf( |
562 | - __('The %s file %s could not be instantiated.','event_espresso'), |
|
562 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
563 | 563 | $type, |
564 | 564 | $class_name |
565 | 565 | ) |
566 | 566 | ); |
567 | 567 | } |
568 | 568 | |
569 | - } catch ( EE_Error $e ) { |
|
569 | + } catch (EE_Error $e) { |
|
570 | 570 | $e->get_error(); |
571 | 571 | } |
572 | 572 | |
@@ -578,15 +578,15 @@ discard block |
||
578 | 578 | // EEH_Debug_Tools::printr( $class_obj, '$class_obj <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
579 | 579 | |
580 | 580 | |
581 | - if ( isset( $class_obj )) { |
|
581 | + if (isset($class_obj)) { |
|
582 | 582 | // return newly instantiated class |
583 | - if ( $class_abbreviation !== '' ) { |
|
583 | + if ($class_abbreviation !== '') { |
|
584 | 584 | $this->{$class_abbreviation} = $class_obj; |
585 | - } else if ( EEH_Class_Tools::has_property( $this, $class_name )) { |
|
585 | + } else if (EEH_Class_Tools::has_property($this, $class_name)) { |
|
586 | 586 | $this->{$class_name} = $class_obj; |
587 | - } else if ( $class_prefix == 'addon' && $cache ) { |
|
587 | + } else if ($class_prefix == 'addon' && $cache) { |
|
588 | 588 | $this->addons->{$class_name} = $class_obj; |
589 | - } else if ( !$from_db && $cache ) { |
|
589 | + } else if ( ! $from_db && $cache) { |
|
590 | 590 | $this->LIB->{$class_name} = $class_obj; |
591 | 591 | } |
592 | 592 | return $class_obj; |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | * @param $a |
612 | 612 | * @param $b |
613 | 613 | */ |
614 | - final function __call($a,$b) {} |
|
614 | + final function __call($a, $b) {} |
|
615 | 615 | |
616 | 616 | |
617 | 617 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * @param $a |
627 | 627 | * @param $b |
628 | 628 | */ |
629 | - final function __set($a,$b) {} |
|
629 | + final function __set($a, $b) {} |
|
630 | 630 | |
631 | 631 | |
632 | 632 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * @param $a |
667 | 667 | * @param $b |
668 | 668 | */ |
669 | - final static function __callStatic($a,$b) {} |
|
669 | + final static function __callStatic($a, $b) {} |
|
670 | 670 | |
671 | 671 | /** |
672 | 672 | * Gets the addon by its name/slug (not classname. For that, just |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | * @param string $name |
675 | 675 | * @return EE_Addon |
676 | 676 | */ |
677 | - public function get_addon_by_name( $name ){ |
|
678 | - foreach($this->addons as $addon){ |
|
679 | - if( $addon->name() == $name){ |
|
677 | + public function get_addon_by_name($name) { |
|
678 | + foreach ($this->addons as $addon) { |
|
679 | + if ($addon->name() == $name) { |
|
680 | 680 | return $addon; |
681 | 681 | } |
682 | 682 | } |
@@ -687,10 +687,10 @@ discard block |
||
687 | 687 | * |
688 | 688 | * @return EE_Addon[] where the KEYS are the addon's name() |
689 | 689 | */ |
690 | - public function get_addons_by_name(){ |
|
690 | + public function get_addons_by_name() { |
|
691 | 691 | $addons = array(); |
692 | - foreach($this->addons as $addon){ |
|
693 | - $addons[ $addon->name() ] = $addon; |
|
692 | + foreach ($this->addons as $addon) { |
|
693 | + $addons[$addon->name()] = $addon; |
|
694 | 694 | } |
695 | 695 | return $addons; |
696 | 696 | } |
@@ -705,14 +705,14 @@ discard block |
||
705 | 705 | * @return EEM_Base |
706 | 706 | * @throws EE_Error |
707 | 707 | */ |
708 | - public function reset_model( $model_name ){ |
|
709 | - $model = $this->load_model( $model_name ); |
|
710 | - $model_class_name = get_class( $model ); |
|
708 | + public function reset_model($model_name) { |
|
709 | + $model = $this->load_model($model_name); |
|
710 | + $model_class_name = get_class($model); |
|
711 | 711 | //get that model reset it and make sure we nuke the old reference to it |
712 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
712 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
713 | 713 | $this->LIB->{$model_class_name} = $model::reset(); |
714 | - }else{ |
|
715 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
714 | + } else { |
|
715 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
716 | 716 | } |
717 | 717 | return $this->LIB->{$model_class_name}; |
718 | 718 | } |
@@ -728,15 +728,15 @@ discard block |
||
728 | 728 | * currently reinstantiate the singletons at the moment) |
729 | 729 | * @return EE_Registry |
730 | 730 | */ |
731 | - public static function reset( $hard = FALSE, $reinstantiate = TRUE ){ |
|
731 | + public static function reset($hard = FALSE, $reinstantiate = TRUE) { |
|
732 | 732 | $instance = self::instance(); |
733 | 733 | $instance->load_helper('Activation'); |
734 | 734 | EEH_Activation::reset(); |
735 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
735 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
736 | 736 | $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset(); |
737 | 737 | $instance->LIB = new stdClass(); |
738 | - foreach( array_keys( $instance->non_abstract_db_models ) as $model_name ){ |
|
739 | - $instance->reset_model( $model_name ); |
|
738 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
739 | + $instance->reset_model($model_name); |
|
740 | 740 | } |
741 | 741 | return $instance; |
742 | 742 | } |
@@ -747,9 +747,9 @@ discard block |
||
747 | 747 | */ |
748 | 748 | public function cpt_models() { |
749 | 749 | $cpt_models = array(); |
750 | - foreach( $this->non_abstract_db_models as $shortname => $classname ) { |
|
751 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
752 | - $cpt_models[ $shortname ] = $classname; |
|
750 | + foreach ($this->non_abstract_db_models as $shortname => $classname) { |
|
751 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
752 | + $cpt_models[$shortname] = $classname; |
|
753 | 753 | } |
754 | 754 | } |
755 | 755 | return $cpt_models; |
@@ -711,7 +711,7 @@ |
||
711 | 711 | //get that model reset it and make sure we nuke the old reference to it |
712 | 712 | if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
713 | 713 | $this->LIB->{$model_class_name} = $model::reset(); |
714 | - }else{ |
|
714 | + } else{ |
|
715 | 715 | throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
716 | 716 | } |
717 | 717 | return $this->LIB->{$model_class_name}; |