[oik] plugins.com

WordPress plugins and themes

  • Home
  • 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.

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.

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

Information

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

Recent plugin updates

oik-weight-zone-shipping v0.2.13 oik-weight-zone-shipping v0.2.13 has been tested with WooCommerce 10.1.2 and WordPress 6.8.2 ...
SB Children Block v1.3.0 Upgrade to SB Children Block v1.3.0 for support for PHP 8.3 and PHP 8.4  ...
oik v4.15.3 Update to oik v4.15.3 for a couple of security fixes. Tested with WordPress 6.8.2 ...
oik-privacy-policy v1.4.9 Update to oik-privacy-policy v1.4.9 for a security fix. Tested with WordPress 6.8.2 and PHP 8.3 and PHP 8.4 ...
oik-nivo-slider v1.17.0 oik-nivo-slider v1.17.0 introduces the Nivo slider block - oik-nivo-slider/nivo. ...

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-2025. All rights reserved.


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

WordPress version: 6.8.3

Gutenberg version: 21.7.0

PHP version: 8.2.29