[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
You are here: Home / WordPress plugins from oik-plugins / FREE oik plugins / oik-bwtrace – debug trace for WordPress / Trace APIs

Trace APIs

When developers are debugging their code, if they are not able to use a debug program, where execution can be followed line by line, they often resort to adding lines of code to trace the values of variables. In many cases they write the output to the web page, or to a file.

The oik-bwtrace plugin provides an easy to use API that assists in the problem determination. It writes its output to a trace file, so it does not alter what you see on the web page.

It can be dynamically enabled and disabled at runtime. The APIs are implemented as lazy APIs. They are dormant until trace is activated and enabled. Therefore, there is no real need to remove the trace (debug) statements when the code goes “live”.

During development of the oik plugins, Bobbing Wide have often resorted to using these trace functions in order to understand some of the stranger behaviour of WordPress, PHP and other plugins and themes.

bw_trace2() function

The bw_trace2() provides an easy way to see content in context.

You appear to be a bot. Output may be restricted

<br />
bw_trace2( $value=null, $text=null, $show_args=true, $trace_level=BW_TRACE_ALWAYS );<br />
 

The variable passed to bw_trace2() may also be an array or object. This enables the developer to quickly see all of the current content of a particular variable.

This function uses debug_backtrace() to determine the function, line and file parameters to report.

By default, bw_trace2() will print the values of the parameters to the function from which it is called to a trace file.

Assuming the value of the $store variable was "2" then
the output that you see in the trace log will be similar to this:

\wp-content\plugins\oik\oik-tides.php(140:0) 2011-09-12T17:02:42+00:00 bw_tides store 2

bw_backtrace() function

The bw_backtrace() function allows you to find out the call hierarchy for a function.
You can see the context in which the function was invoked; call stack and parameters.
Use this function sparingly.

You appear to be a bot. Output may be restricted

<br />
bw_backtrace();<br />
 

bw_gobang() – Go Bang!

Or whatever you want it to be, so long as it doesn’t exist.
We use this mythical function to get a fatal error.


if ( $this != $that ) {
bw_trace2( $this, "this" );
bw_trace2( $that, "that", false );
bw_backtrace();
gobang();
}
crash();
 

It’s good when you want to demonstrate that your code IS being run.
Use this function even more sparingly than bw_backtrace().

Published: December 4, 2019 | Last updated: December 1, 2020

Information

Component:
  • oik-bwtrace – debug trace for WordPress
Letters: T

Recent plugin updates

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 ...
UK-tides v3.1.0 UK-tides v3.1.0 now supports several additional ports. It's built with latest wp-scripts and shared libraries and tested with WordPress 6.1. ...
oik v4.8.2 Upgrade to oik v4.8.2 if you installed oik v4.8.1 from wordpress.org and found that the blocks were missing from the editor. ...
sb-chart-block v1.1.0 sb-chart-block v1.1.0 now uses chart.js v3.9.1. Tested with WordPress 6.0.1 and Gutenberg 13.8.2 ...

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