• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

[oik] plugins.com

WordPress plugins and themes

  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

What are the public trace APIs?

Q. What are the trace APIs that I can use in my plugin or theme?
A. bw_trace2(), bw_trace(), and bw_backtrace().

bw_trace2()

Easy to use tracing. When invoked without parameters it will report the values of the parameters passed to its calling function. e.g.

You appear to be a bot. Output may be restricted


function my_func( $param1, $param2=null ) {
  bw_trace2();
}
 
This will produce a trace record for my_func, showing the parameter values in an array.
my_func.php(4:0) my_func(1) 1 2015-07-28T11:07:54+00:00 0.000008 0.000008 cf! F=21 2 Array
(
    [0] => Trace example
    [1] => 4445
)
When parameters are passed to bw_trace2() it traces these.

function my_func2() {
  $var = "Trace me";
  bw_trace2( $var );
  $arr = array( "Trace me", "array" );
  bw_trace2( $arr, "array", false );
}
 
my_func.php(9:0) my_func2(1) 2 2015-07-28T11:29:12+00:00 0.001089 0.001081 cf! F=21 0 
my_func.php(9:0) my_func2(2) 3 2015-07-28T11:29:12+00:00 0.001660 0.000571 cf! F=21  Trace me
my_func.php(11:0) my_func2(3) 4 2015-07-28T11:29:12+00:00 0.002249 0.000589 cf! F=21 array Array
(
    [0] => Trace me
    [1] => array
)
If you don’t pass a label, parameters which may be null or 0 are not traced. When this happens the absence of the trace record indicates the value is null. This is useful when you have more than one call to bw_trace2() in a function. If you pass false as the third parameter, then the parameters to the function that invokes bw_trace2() are not reproduced; you get fewer trace records.

bw_trace()

This is a lower level function than bw_trace2(). You need to pass it more parameters. Use bw_trace2() in preference to bw_trace().

bw_backtrace()

This shows the context in which the current code has been invoked.

You appear to be a bot. Output may be restricted


function my_func_gets_called_where() {
  bw_backtrace();
}
 
Example
0. bw_lazy_backtrace libs\bwtrace.php:72 0
1. bw_backtrace my_func.php:15 0
2. my_func_gets_called_where my_func.php:19 0
3. require_once(my_func.php) oik-batch\oik-batch.php:313 1
4. oik_batch_run_script(my_func.php) oik-batch\oik-batch.php:350 1
5. oik_batch_run oik-batch\oik-batch.php:274 0
6. oik_batch_loaded oik-batch\oik-batch.php:356 0

Notes

  • These are dormant APIs provided by the oik base and oik-lib plugins
  • Each API is a wrapper to a lazy function
  • The oik-bwtrace plugin implements the lazy functions
  • For implementation details see
    • bw_backtrace() – Log a debug_backtrace() to the trace log file if tracing is active
    • bw_trace() – Log a simple trace record to the trace log file if tracing is active
    • bw_trace2() – Trace $value to the trace log file if tracing is active
  • In these examples most of the path to the files has been stripped

Published: June 5, 2015 | Last updated: July 28, 2015

Primary Sidebar

Information

Component:
  • oik-bwtrace – debug trace for WordPress
Question has actually been asked: No
Letters:

Recent plugin updates

oik-fields v1.55.1
oik-fields v1.55.1 oik-fields v1.55.1 has been tested with WordPress 7.1. ...
oik v4.16.0
oik v4.16.0 Upgrade to oik v4.16.0 for many accessibility (a11y) improvements for both the front end and admin areas, plus a security fix. ...
oik-fields v1.55.0
oik-fields v1.55.0 Upgrade to oik-fields v1.55.0 for accessibility improvements to the featured image virtual field. ...
oik-css v2.4.0
oik-css v2.4.0 Upgrade to oik-css v2.4.0 for accessibility improvements for Low Color Contrast errors. ...
oik-unloader v0.4.0
oik-unloader v0.4.0 Update to oik-unloader v0.4.0 for improved accessibility of the active-plugins shortcode. Tested with WordPress 6.9 and PHP 8.4 ...

Footer

Plugins

  • All Plugins
  • oik base plugin
  • FREE oik plugins
  • WordPress plugins
  • Premium oik plugins

Themes

  • FREE themes
  • Bespoke themes
  • Premium themes

Blocks

  • All Blocks
  • Block examples
  • About Blocks

Shortcodes

  • All Shortcodes
  • Shortcode examples
  • About Shortcodes

Reference

  • About APIs
  • All APIs
  • All Classes
  • All Files
  • All Hooks

Support

  • Contact
  • Cookies policy
  • Get API key
  • Privacy
  • Request support
  • Sitemap
  • Stay informed
  • Terms and Conditions
oik-plugins
Email: oikplug@oik-plugins.com

Weight shipping plugins

Find out which cart weight shipping plugin you need for your WooCommerce site.
Which cart weight based plugin do I need?

Site:  www.oik-plugins.com
© Copyright oik-plugins 2011-2026. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins

WordPress version: 7.1.2

Gutenberg version: 24.0.0

PHP version: 8.2.35