[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.

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

Information

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

Recent plugin updates

oik-weight-zone-shipping v0.2.6 oik-weight-zone-shipping v0.2.6 has been tested with WooCommerce 7.4.0. ...
sb-chart-block v1.2.3 SB Chart Block v1.2.3 contains a fix for an Uncaught Error: Call to undefined function bw_trace2()  ...
SB Chart Block v1.2.1 Update to SB Chart Block v1.2.0 for custom colors, font size options and multiple y-axis charts.  ...
oik-css v2.1.0 Update to oik-css v2.1.0 for the ability to style CSS and GeSHi output in documentation. ...
oik-types v2.3.0 Update to oik-types v2.3.0 for improved control over sort order on archives ...

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


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins
WordPress 6.1.1. PHP: 7.4.33. Memory limit: 768M