The oik-bwtrace plugin provides a trace mechanism for problem determination of WordPress plugins and themes and even core code.
- The primary purpose of debug trace is to help in the development of PHP code: plugins or themes.
- The primary purpose of action and filter trace is to help you follow the sequence of events in the server.
- The primary purpose of Immediate action and filter trace is to show you all the actions and filters that are invoked.
- This plugin provides the admin interface to trace functions and action and filter tracing built into plugins that use the oik / bw 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. 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
Introduced in oik version 1.6 the bw_trace2() is easier to use than bw_trace() as it requires less coding.
bw_trace2( $value=null, $text=null, $show_args=true );
This function uses bw_backtrace() to determine the function, line and file parameters to pass to bw_trace(). By default, bw_trace2() will print the values of the parameters to the function from which it is called to the trace log file. You can view the file using your web browser.
bw_trace() function
At the heart of the oik trace plugin is the bw_trace() function call. Whenever you need to find the value of a variable you simply code something like the following line
bw_trace( $store, __FUNCTION__, __LINE__, __FILE__, "store" );
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
The variable passed to bw_trace() may also be an array or object. This enables the developer to quickly see all of the current content of a particular variable.
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.
bw_gobang()
Or whatever you want it to be, so long as it doesn’t exist.
We use this mythical function to get a fatal error. It’s good when you want to demonstrate that your code IS being run. Use this function even more sparingly than bw_backtrace().
- Settings > oik trace options
- Settings > oik action options
- Debug trace dependency on the oik base plugin
- Start tracing from wp-config.php
- oik-bwtrace modifications to wp-includes/plugin.php
- oik-bwtrace output file - bwtrace.loh
- oik-bwtrace action and filter trace file - bwaction.loh
- WordPress plugins for debugging or problem determination






Recent Comments