| | 460 | |
| | 461 | /** |
| | 462 | * Get the name of the function that called wpdb. |
| | 463 | * @return string the name of the calling function |
| | 464 | */ |
| | 465 | function get_caller() { |
| | 466 | // requires PHP 4.3+ |
| | 467 | if ( !is_callable('debug_backtrace') ) |
| | 468 | return ''; |
| | 469 | |
| | 470 | $bt = debug_backtrace(); |
| | 471 | $caller = ''; |
| | 472 | |
| | 473 | foreach ( $bt as $trace ) { |
| | 474 | if ( @$trace['class'] == __CLASS__ ) |
| | 475 | continue; |
| | 476 | elseif ( strtolower(@$trace['function']) == 'call_user_func_array' ) |
| | 477 | continue; |
| | 478 | elseif ( strtolower(@$trace['function']) == 'apply_filters' ) |
| | 479 | continue; |
| | 480 | elseif ( strtolower(@$trace['function']) == 'do_action' ) |
| | 481 | continue; |
| | 482 | |
| | 483 | $caller = $trace['function']; |
| | 484 | break; |
| | 485 | } |
| | 486 | return $caller; |
| | 487 | } |
| | 488 | |