функция
since 3.4.0
wp_debug_backtrace_summary()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_debug_backtrace_summary( string $ignore_class = null, int $skip_frames, bool $pretty = true ): string|array
Описание
Смотрите такжеhttps://core.trac.wordpress.org/ticket/19589
Оригинал (английский)
Параметры
$ignore_class
string
необязательный
= null
Класс, все вызовы функций внутри которого игнорируются — удобно, когда нужно дать сведения только о вызываемой стороне.
$skip_frames
int
необязательный
Количество кадров стека, которые нужно пропустить — удобно для возврата к источнику проблемы. По умолчанию 0.
$pretty
bool
необязательный
= true
Нужно ли вернуть строку с разделителями-запятыми вместо необработанного массива.
Возвращаемое значение
string|array
Исходный код
wp-includes/functions.php:7279
function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
static $truncate_paths;
$trace = debug_backtrace( false );
$caller = array();
$check_class = ! is_null( $ignore_class );
++$skip_frames; // Skip this function.
if ( ! isset( $truncate_paths ) ) {
$truncate_paths = array(
wp_normalize_path( WP_CONTENT_DIR ),
wp_normalize_path( ABSPATH ),
);
}
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', 'do_action_ref_array', 'apply_filters_ref_array' ), true ) ) {
$caller[] = "{$call['function']}('{$call['args'][0]}')";
} elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ), true ) ) {
$filename = $call['args'][0] ?? '';
$caller[] = $call['function'] . "('" . str_replace( $truncate_paths, '', wp_normalize_path( $filename ) ) . "')";
} else {
$caller[] = $call['function'];
}
}
}
if ( $pretty ) {
return implode( ', ', array_reverse( $caller ) );
} else {
return $caller;
}
}
История изменений
| Версия | Описание |
|---|---|
| 3.4.0 | Introduced. |

