| | 478 | |
|---|
| | 479 | /** |
|---|
| | 480 | * Get the name of the function that called wpdb. |
|---|
| | 481 | * @return string the name of the calling function |
|---|
| | 482 | */ |
|---|
| | 483 | function get_caller() { |
|---|
| | 484 | // requires PHP 4.3+ |
|---|
| | 485 | if ( !is_callable('debug_backtrace') ) |
|---|
| | 486 | return ''; |
|---|
| | 487 | |
|---|
| | 488 | $bt = debug_backtrace(); |
|---|
| | 489 | $caller = ''; |
|---|
| | 490 | |
|---|
| | 491 | foreach ( $bt as $trace ) { |
|---|
| | 492 | if ( @$trace['class'] == __CLASS__ ) |
|---|
| | 493 | continue; |
|---|
| | 494 | elseif ( strtolower(@$trace['function']) == 'call_user_func_array' ) |
|---|
| | 495 | continue; |
|---|
| | 496 | elseif ( strtolower(@$trace['function']) == 'apply_filters' ) |
|---|
| | 497 | continue; |
|---|
| | 498 | elseif ( strtolower(@$trace['function']) == 'do_action' ) |
|---|
| | 499 | continue; |
|---|
| | 500 | |
|---|
| | 501 | $caller = $trace['function']; |
|---|
| | 502 | break; |
|---|
| | 503 | } |
|---|
| | 504 | return $caller; |
|---|
| | 505 | } |
|---|
| | 506 | |
|---|