wp_debug_backtrace_summary

The timeline below displays how wordpress function wp_debug_backtrace_summary has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Returns a comma-separated string or array of functions that have been called to get
 * to the current point in code.
 *
 * @since 3.4.0
 *
 * @see https://core.trac.wordpress.org/ticket/19589
 *
 * @param string $ignore_class Optional. A class to ignore all function calls within - useful
 *                             when you want to just give info about the callee. Default null.
 * @param int    $skip_frames  Optional. A number of stack frames to skip - useful for unwinding
 *                             back to the source of the issue. Default 0.
 * @param bool   $pretty       Optional. Whether you want a comma separated string instead of
 *                             the raw array returned. Default true.
 * @return string|array Either a string containing a reversed comma separated trace or an array
 *                      of individual calls.
 */
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 = isset($call['args'][0]) ? $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;
    }
}

WordPress Version: 6.1

/**
 * Returns a comma-separated string or array of functions that have been called to get
 * to the current point in code.
 *
 * @since 3.4.0
 *
 * @see https://core.trac.wordpress.org/ticket/19589
 *
 * @param string $ignore_class Optional. A class to ignore all function calls within - useful
 *                             when you want to just give info about the callee. Default null.
 * @param int    $skip_frames  Optional. A number of stack frames to skip - useful for unwinding
 *                             back to the source of the issue. Default 0.
 * @param bool   $pretty       Optional. Whether you want a comma separated string instead of
 *                             the raw array returned. Default true.
 * @return string|array Either a string containing a reversed comma separated trace or an array
 *                      of individual calls.
 */
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 = isset($call['args'][0]) ? $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;
    }
}

WordPress Version: 5.6

/**
 * Return a comma-separated string of functions that have been called to get
 * to the current point in code.
 *
 * @since 3.4.0
 *
 * @see https://core.trac.wordpress.org/ticket/19589
 *
 * @param string $ignore_class Optional. A class to ignore all function calls within - useful
 *                             when you want to just give info about the callee. Default null.
 * @param int    $skip_frames  Optional. A number of stack frames to skip - useful for unwinding
 *                             back to the source of the issue. Default 0.
 * @param bool   $pretty       Optional. Whether or not you want a comma separated string or raw
 *                             array returned. Default true.
 * @return string|array Either a string containing a reversed comma separated trace or an array
 *                      of individual calls.
 */
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 = isset($call['args'][0]) ? $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;
    }
}

WordPress Version: 5.5

/**
 * Return a comma-separated string of functions that have been called to get
 * to the current point in code.
 *
 * @since 3.4.0
 *
 * @see https://core.trac.wordpress.org/ticket/19589
 *
 * @param string $ignore_class Optional. A class to ignore all function calls within - useful
 *                             when you want to just give info about the callee. Default null.
 * @param int    $skip_frames  Optional. A number of stack frames to skip - useful for unwinding
 *                             back to the source of the issue. Default 0.
 * @param bool   $pretty       Optional. Whether or not you want a comma separated string or raw
 *                             array returned. Default true.
 * @return string|array Either a string containing a reversed comma separated trace or an array
 *                      of individual calls.
 */
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 = isset($call['args'][0]) ? $call['args'][0] : '';
            $caller[] = $call['function'] . "('" . str_replace($truncate_paths, '', wp_normalize_path($filename)) . "')";
        } else {
            $caller[] = $call['function'];
        }
    }
    if ($pretty) {
        return join(', ', array_reverse($caller));
    } else {
        return $caller;
    }
}

WordPress Version: 5.4

/**
 * Return a comma-separated string of functions that have been called to get
 * to the current point in code.
 *
 * @since 3.4.0
 *
 * @see https://core.trac.wordpress.org/ticket/19589
 *
 * @staticvar array $truncate_paths Array of paths to truncate.
 *
 * @param string $ignore_class Optional. A class to ignore all function calls within - useful
 *                             when you want to just give info about the callee. Default null.
 * @param int    $skip_frames  Optional. A number of stack frames to skip - useful for unwinding
 *                             back to the source of the issue. Default 0.
 * @param bool   $pretty       Optional. Whether or not you want a comma separated string or raw
 *                             array returned. Default true.
 * @return string|array Either a string containing a reversed comma separated trace or an array
 *                      of individual calls.
 */
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'))) {
            $caller[] = "{$call['function']}('{$call['args'][0]}')";
        } elseif (in_array($call['function'], array('include', 'include_once', 'require', 'require_once'))) {
            $filename = isset($call['args'][0]) ? $call['args'][0] : '';
            $caller[] = $call['function'] . "('" . str_replace($truncate_paths, '', wp_normalize_path($filename)) . "')";
        } else {
            $caller[] = $call['function'];
        }
    }
    if ($pretty) {
        return join(', ', array_reverse($caller));
    } else {
        return $caller;
    }
}

WordPress Version: 5.3

/**
 * Return a comma-separated string of functions that have been called to get
 * to the current point in code.
 *
 * @since 3.4.0
 *
 * @see https://core.trac.wordpress.org/ticket/19589
 *
 * @staticvar array $truncate_paths Array of paths to truncate.
 *
 * @param string $ignore_class Optional. A class to ignore all function calls within - useful
 *                             when you want to just give info about the callee. Default null.
 * @param int    $skip_frames  Optional. A number of stack frames to skip - useful for unwinding
 *                             back to the source of the issue. Default 0.
 * @param bool   $pretty       Optional. Whether or not you want a comma separated string or raw
 *                             array returned. Default true.
 * @return string|array Either a string containing a reversed comma separated trace or an array
 *                      of individual calls.
 */
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'))) {
            $caller[] = "{$call['function']}('{$call['args'][0]}')";
        } elseif (in_array($call['function'], array('include', 'include_once', 'require', 'require_once'))) {
            $filename = isset($call['args'][0]) ? $call['args'][0] : '';
            $caller[] = $call['function'] . "('" . str_replace($truncate_paths, '', wp_normalize_path($filename)) . "')";
        } else {
            $caller[] = $call['function'];
        }
    }
    if ($pretty) {
        return join(', ', array_reverse($caller));
    } else {
        return $caller;
    }
}

WordPress Version: 5.1

/**
 * Return a comma-separated string of functions that have been called to get
 * to the current point in code.
 *
 * @since 3.4.0
 *
 * @see https://core.trac.wordpress.org/ticket/19589
 *
 * @staticvar array $truncate_paths Array of paths to truncate.
 *
 * @param string $ignore_class Optional. A class to ignore all function calls within - useful
 *                             when you want to just give info about the callee. Default null.
 * @param int    $skip_frames  Optional. A number of stack frames to skip - useful for unwinding
 *                             back to the source of the issue. Default 0.
 * @param bool   $pretty       Optional. Whether or not you want a comma separated string or raw
 *                             array returned. Default true.
 * @return string|array Either a string containing a reversed comma separated trace or an array
 *                      of individual calls.
 */
function wp_debug_backtrace_summary($ignore_class = null, $skip_frames = 0, $pretty = true)
{
    static $truncate_paths;
    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
    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'))) {
            $caller[] = "{$call['function']}('{$call['args'][0]}')";
        } elseif (in_array($call['function'], array('include', 'include_once', 'require', 'require_once'))) {
            $filename = isset($call['args'][0]) ? $call['args'][0] : '';
            $caller[] = $call['function'] . "('" . str_replace($truncate_paths, '', wp_normalize_path($filename)) . "')";
        } else {
            $caller[] = $call['function'];
        }
    }
    if ($pretty) {
        return join(', ', array_reverse($caller));
    } else {
        return $caller;
    }
}

WordPress Version: 4.1

/**
 * Return a comma-separated string of functions that have been called to get
 * to the current point in code.
 *
 * @since 3.4.0
 *
 * @see https://core.trac.wordpress.org/ticket/19589
 *
 * @param string $ignore_class Optional. A class to ignore all function calls within - useful
 *                             when you want to just give info about the callee. Default null.
 * @param int    $skip_frames  Optional. A number of stack frames to skip - useful for unwinding
 *                             back to the source of the issue. Default 0.
 * @param bool   $pretty       Optional. Whether or not you want a comma separated string or raw
 *                             array returned. Default true.
 * @return string|array Either a string containing a reversed comma separated trace or an array
 *                      of individual calls.
 */
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;
    }
}

WordPress Version: 4.0

/**
 * Return a comma-separated string of functions that have been called to get
 * to the current point in code.
 *
 * @since 3.4.0
 *
 * @see http://core.trac.wordpress.org/ticket/19589
 *
 * @param string $ignore_class Optional. A class to ignore all function calls within - useful
 *                             when you want to just give info about the callee. Default null.
 * @param int    $skip_frames  Optional. A number of stack frames to skip - useful for unwinding
 *                             back to the source of the issue. Default 0.
 * @param bool   $pretty       Optional. Whether or not you want a comma separated string or raw
 *                             array returned. Default true.
 * @return string|array Either a string containing a reversed comma separated trace or an array
 *                      of individual calls.
 */
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;
    }
}

WordPress Version: 3.8

/**
 * Return a comma separated string of functions that have been called to get to the current point in code.
 *
 * @link http://core.trac.wordpress.org/ticket/19589
 * @since 3.4.0
 *
 * @param string $ignore_class A class to ignore all function calls within - useful when you want to just give info about the callee
 * @param int $skip_frames A number of stack frames to skip - useful for unwinding back to the source of the issue
 * @param bool $pretty Whether or not you want a comma separated string or raw array returned
 * @return string|array Either a string containing a reversed comma separated trace or an array of individual calls.
 */
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;
    }
}

WordPress Version: 3.7

/**
 * Return a comma separated string of functions that have been called to get to the current point in code.
 *
 * @link http://core.trac.wordpress.org/ticket/19589
 * @since 3.4
 *
 * @param string $ignore_class A class to ignore all function calls within - useful when you want to just give info about the callee
 * @param int $skip_frames A number of stack frames to skip - useful for unwinding back to the source of the issue
 * @param bool $pretty Whether or not you want a comma separated string or raw array returned
 * @return string|array Either a string containing a reversed comma separated trace or an array of individual calls.
 */
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;
    }
}