返回介绍

wp_debug_backtrace_summary()

发布于 2017-09-11 11:47:30 字数 2857 浏览 919 评论 0 收藏 0

wp_debug_backtrace_summary( string $ignore_class = null,  int $skip_frames,  bool $pretty = true )

Return a comma-separated string of functions that have been called to get to the current point in code.


description


参数

$ignore_class

(string) (Optional) A class to ignore all function calls within - useful when you want to just give info about the callee.

Default value: null

$skip_frames

(int) (Optional) A number of stack frames to skip - useful for unwinding back to the 源代码 of the issue. Default 0.

$pretty

(bool) (Optional) Whether or not you want a comma separated string or raw array returned.

Default value: true


返回值

(string|array) Either a string containing a reversed comma separated trace or an array of individual calls.


源代码

File: wp-includes/functions.php

function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
	if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) )
		$trace = debug_backtrace( false );
	else
		$trace = debug_backtrace();

	$caller = array();
	$check_class = ! is_null( $ignore_class );
	$skip_frames++; // skip this function

	foreach ( $trace as $call ) {
		if ( $skip_frames > 0 ) {
			$skip_frames--;
		} elseif ( isset( $call['class'] ) ) {
			if ( $check_class && $ignore_class == $call['class'] )
				continue; // Filter out calls

			$caller[] = "{$call['class']}{$call['type']}{$call['function']}";
		} else {
			if ( in_array( $call['function'], array( 'do_action', 'apply_filters' ) ) ) {
				$caller[] = "{$call['function']}('{$call['args'][0]}')";
			} elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) {
				$caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) , '', $call['args'][0] ) . "')";
			} else {
				$caller[] = $call['function'];
			}
		}
	}
	if ( $pretty )
		return join( ', ', array_reverse( $caller ) );
	else
		return $caller;
}

更新日志

Versiondescription
3.4.0Introduced.

相关函数

Used By

  • wp-includes/wp-db.php: wpdb::get_caller()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文