-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.php
49 lines (36 loc) · 945 Bytes
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Helper functions
*/
/**
* Send debugging messages when WP_DEBUG is enbaled.
*
* @param string $msg the message for error
* @param array $functions the functions used
*/
function axio_core_debug_msg($msg, $functions) {
if (WP_DEBUG === true) {
// init warning to get source
$e = new Exception($msg);
// find file and line for problem
$trace_line = '';
foreach ($e->getTrace() as $trace) {
if (in_array($trace['function'], $functions)) {
$trace_line = ' in ' . $trace['file'] . ':' . $trace['line'];
}
}
// compose error message
$error_msg = $e->getMessage() . $trace_line;
// trigger errors
trigger_error($error_msg, E_USER_WARNING);
error_log($error_msg);
}
}
/**
* Support legacy function
*/
if (!function_exists('aucor_core_debug_msg')) {
function aucor_core_debug_msg($msg, $functions) {
axio_core_debug_msg($msg, $functions);
}
}