{"id":40210,"date":"2019-12-04T12:04:24","date_gmt":"2019-12-04T12:04:24","guid":{"rendered":"https:\/\/s.b\/oikcom\/?page_id=34834"},"modified":"2020-12-01T16:26:30","modified_gmt":"2020-12-01T16:26:30","slug":"trace-apis","status":"publish","type":"page","link":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/","title":{"rendered":"Trace APIs"},"content":{"rendered":"\n<p>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.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>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 &#8220;live&#8221;.<\/p>\n\n\n\n<p>During development of the <span class=\"bw_oik\"><abbr  title=\"OIK Information Kit\">oik<\/abbr><\/span> plugins, <em class=\"bw_b1\">B<\/em><em class=\"bw_o\">o<\/em><em class=\"bw_b2\">b<\/em><em class=\"bw_b3\">b<\/em><em class=\"bw_i1\">i<\/em><em class=\"bw_n\">n<\/em><em class=\"bw_g\">g<\/em><em class=\"bw_space\">&nbsp;<\/em><em class=\"bw_W\">W<\/em><em class=\"bw_i2\">i<\/em><em class=\"bw_d\">d<\/em><em class=\"bw_e\">e<\/em> have often resorted to using these trace functions in order to understand some of the stranger behaviour of <span class=\"wordpress\"><span class=\"bw_word\">Word<\/span><span class=\"bw_press\">Press<\/span><\/span>, PHP and other plugins and themes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">bw_trace2() function<\/h3>\n\n\n\n<p>The <a class=\"bw_api\" href=\"https:\/\/www.oik-plugins.com\/oik_api\/bw_trace2\/\">bw_trace2<\/a>() provides an easy way to see content in context.<br><\/p>\n\n\n<p><pre><span><<\/span><span class=\"T_STRING\" id=\"1\"><a href=\"\/oik_api\/br\/\" title=\"br() &#8211; Produce a break tag with optional text to follow\">br<\/a><\/span><span class=\"T_WHITESPACE\" id=\"2\"> <\/span><span>\/<\/span><span>><\/span><span class=\"T_WHITESPACE\" id=\"5\">\n<\/span><span class=\"T_STRING\" id=\"6\"><a href=\"\/oik_api\/bw_trace2\/\" title=\"bw_trace2() &#8211; Trace $value to the trace log file if tracing is active\">bw_trace2<\/a><\/span><span>(<\/span><span class=\"T_WHITESPACE\" id=\"8\"> <\/span><span class=\"T_VARIABLE\" id=\"9\">$value<\/span><span>=<\/span><span class=\"T_STRING\" id=\"11\">null<\/span><span>,<\/span><span class=\"T_WHITESPACE\" id=\"13\"> <\/span><span class=\"T_VARIABLE\" id=\"14\">$text<\/span><span>=<\/span><span class=\"T_STRING\" id=\"16\">null<\/span><span>,<\/span><span class=\"T_WHITESPACE\" id=\"18\"> <\/span><span class=\"T_VARIABLE\" id=\"19\">$show_args<\/span><span>=<\/span><span class=\"T_STRING\" id=\"21\">true<\/span><span>,<\/span><span class=\"T_WHITESPACE\" id=\"23\"> <\/span><span class=\"T_VARIABLE\" id=\"24\">$trace_level<\/span><span>=<\/span><span class=\"T_STRING\" id=\"26\">BW_TRACE_ALWAYS<\/span><span class=\"T_WHITESPACE\" id=\"27\"> <\/span><span>)<\/span><span>;<\/span><span><<\/span><span class=\"T_STRING\" id=\"31\"><a href=\"\/oik_api\/br\/\" title=\"br() &#8211; Produce a break tag with optional text to follow\">br<\/a><\/span><span class=\"T_WHITESPACE\" id=\"32\"> <\/span><span>\/<\/span><span>><\/span><span class=\"T_WHITESPACE\" id=\"35\">\n<\/span>&nbsp;<\/pre><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>This function uses <a href=\"https:\/\/www.php.net\/manual\/en\/function.debug-backtrace.php\" title=\"PHP docs for: debug_backtrace\">debug_backtrace<\/a>() to determine the function, line and file parameters to report.<\/p>\n\n\n\n<p>By default, bw_trace2() will print the values of the parameters to the function from which it is called to a trace file.<\/p>\n\n\n\n\n\n<p>Assuming the value of the <code>$store<\/code> variable was <code>\"2\"<\/code> then<br>the output that you see in the trace log will be similar to this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\\wp-content\\plugins\\oik\\oik-tides.php(140:0) 2011-09-12T17:02:42+00:00 bw_tides store 2\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">bw_backtrace() function<\/h3>\n\n\n\n<p>The <a class=\"bw_api\" href=\"https:\/\/www.oik-plugins.com\/oik_api\/bw_backtrace\/\">bw_backtrace<\/a>() function allows you to find out the call hierarchy for a function.<br>You can see the context in which the function was invoked; call stack and parameters.<br>Use this function sparingly.<\/p>\n\n\n<p><pre><span><<\/span><span class=\"T_STRING\" id=\"1\"><a href=\"\/oik_api\/br\/\" title=\"br() &#8211; Produce a break tag with optional text to follow\">br<\/a><\/span><span class=\"T_WHITESPACE\" id=\"2\"> <\/span><span>\/<\/span><span>><\/span><span class=\"T_WHITESPACE\" id=\"5\">\n<\/span><span class=\"T_STRING\" id=\"6\"><a href=\"\/oik_api\/bw_backtrace\/\" title=\"bw_backtrace() &#8211; Log a debug_backtrace() to the trace log file if tracing is active\">bw_backtrace<\/a><\/span><span>(<\/span><span>)<\/span><span>;<\/span><span><<\/span><span class=\"T_STRING\" id=\"11\"><a href=\"\/oik_api\/br\/\" title=\"br() &#8211; Produce a break tag with optional text to follow\">br<\/a><\/span><span class=\"T_WHITESPACE\" id=\"12\"> <\/span><span>\/<\/span><span>><\/span><span class=\"T_WHITESPACE\" id=\"15\">\n<\/span>&nbsp;<\/pre><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">bw_gobang() &#8211; Go Bang!<\/h3>\n\n\n\n<p>Or whatever you want it to be, so long as it doesn&#8217;t exist.<br>We use this mythical function to get a fatal error.<\/p>\n\n\n<p><div class=\"bw_geshi php\"><code><br \/>\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #009900;\">&#40;<\/span> <span style=\"color: #000088;\">$this<\/span> <span style=\"color: #339933;\">!=<\/span> <span style=\"color: #000088;\">$that<\/span> <span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\nbw_trace2<span style=\"color: #009900;\">&#40;<\/span> <span style=\"color: #000088;\">$this<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #0000ff;\">&quot;this&quot;<\/span> <span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nbw_trace2<span style=\"color: #009900;\">&#40;<\/span> <span style=\"color: #000088;\">$that<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #0000ff;\">&quot;that&quot;<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900; font-weight: bold;\">false<\/span> <span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nbw_backtrace<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\ngobang<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\ncrash<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<\/code><\/div><\/p>\n\n\n\n<p>It&#8217;s good when you want to demonstrate that your code IS being run.<br>Use this function even more sparingly than bw_backtrace().<\/p>\n","protected":false},"excerpt":{"rendered":"<p><!-- wp:paragraph --><\/p>\n<p>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.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>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.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>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 &#8220;live&#8221;.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>During development of the <span class=\"bw_oik\"><abbr  title=\"OIK Information Kit\">oik<\/abbr><\/span> plugins, <em class=\"bw_b1\">B<\/em><em class=\"bw_o\">o<\/em><em class=\"bw_b2\">b<\/em><em class=\"bw_b3\">b<\/em><em class=\"bw_i1\">i<\/em><em class=\"bw_n\">n<\/em><em class=\"bw_g\">g<\/em><em class=\"bw_space\">&nbsp;<\/em><em class=\"bw_W\">W<\/em><em class=\"bw_i2\">i<\/em><em class=\"bw_d\">d<\/em><em class=\"bw_e\">e<\/em> have often resorted to using these trace functions in order to understand some of the stranger behaviour of <span class=\"wordpress\"><span class=\"bw_word\">Word<\/span><span class=\"bw_press\">Press<\/span><\/span>, PHP and other plugins and themes.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3>bw_trace2() function<\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>The <a class=\"bw_api\" href=\"https:\/\/www.oik-plugins.com\/oik_api\/bw_trace2\/\">bw_trace2<\/a>() provides an easy way to see content in context.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:shortcode --><\/p>\n<pre><span class=\"T_WHITESPACE\">\n<\/span><span class=\"T_STRING\" id=\"1\"><a href=\"\/oik_api\/bw_trace2\/\" title=\"bw_trace2() &#8211; Trace $value to the trace log file if tracing is active\">bw_trace2<\/a><\/span><span>(<\/span><span class=\"T_WHITESPACE\" id=\"3\"> <\/span><span class=\"T_VARIABLE\" id=\"4\">$value<\/span><span>=<\/span><span class=\"T_STRING\" id=\"6\">null<\/span><span>,<\/span><span class=\"T_WHITESPACE\" id=\"8\"> <\/span><span class=\"T_VARIABLE\" id=\"9\">$text<\/span><span>=<\/span><span class=\"T_STRING\" id=\"11\">null<\/span><span>,<\/span><span class=\"T_WHITESPACE\" id=\"13\"> <\/span><span class=\"T_VARIABLE\" id=\"14\">$show_args<\/span><span>=<\/span><span class=\"T_STRING\" id=\"16\">true<\/span><span>,<\/span><span class=\"T_WHITESPACE\" id=\"18\"> <\/span><span class=\"T_VARIABLE\" id=\"19\">$trace_level<\/span><span>=<\/span><span class=\"T_STRING\" id=\"21\">BW_TRACE_ALWAYS<\/span><span class=\"T_WHITESPACE\" id=\"22\"> <\/span><span>)<\/span><span>;<\/span><span class=\"T_WHITESPACE\" id=\"25\">\n<\/span>&nbsp;<\/pre>\n<p><!-- \/wp:shortcode --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>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.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>This function uses <a href=\"https:\/\/www.php.net\/manual\/en\/function.debug-backtrace.php\" title=\"PHP docs for: debug_backtrace\">debug_backtrace<\/a>() to determine the function, line and file parameters to report.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>By default, bw_trace2() will print the values of the parameters to the function from which it is called to a trace file.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:oik-block\/geshi {\"lang\":\"php\",\"content\":\"bw_trace2( $store, 'store' );\"} \/--><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Assuming the value of the <code>$store<\/code> variable was <code>\"2\"<\/code> then<br \/>the output that you see in the trace log will be similar to this:<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:preformatted --><\/p>\n<pre class=\"wp-block-preformatted\">\\wp-content\\plugins\\oik\\oik-tides.php(140:0) 2011-09-12T17:02:42+00:00 bw_tides store 2\n<\/pre>\n<p><!-- \/wp:preformatted --><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3>bw_backtrace() function<\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>The <a class=\"bw_api\" href=\"https:\/\/www.oik-plugins.com\/oik_api\/bw_backtrace\/\">bw_backtrace<\/a>() function allows you to find out the call hierarchy for a function.<br \/>You can see the context in which the function was invoked; call stack and parameters.<br \/>Use this function sparingly.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:shortcode --><\/p>\n<pre><span class=\"T_WHITESPACE\">\n<\/span><span class=\"T_STRING\" id=\"1\"><a href=\"\/oik_api\/bw_backtrace\/\" title=\"bw_backtrace() &#8211; Log a debug_backtrace() to the trace log file if tracing is active\">bw_backtrace<\/a><\/span><span>(<\/span><span>)<\/span><span>;<\/span><span class=\"T_WHITESPACE\" id=\"5\">\n<\/span>&nbsp;<\/pre>\n<p><!-- \/wp:shortcode --><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3>bw_gobang() &#8211; Go Bang!<\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>Or whatever you want it to be, so long as it doesn&#8217;t exist.<br \/>We use this mythical function to get a fatal error.<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n<p><!-- wp:shortcode --><\/p>\n<div class=\"bw_geshi php\"><code><br \/>\n<span style=\"color: #b1b100;\">if<\/span> <span style=\"color: #009900;\">&#40;<\/span> <span style=\"color: #000088;\">$this<\/span> <span style=\"color: #339933;\">!=<\/span> <span style=\"color: #000088;\">$that<\/span> <span style=\"color: #009900;\">&#41;<\/span> <span style=\"color: #009900;\">&#123;<\/span><br \/>\nbw_trace2<span style=\"color: #009900;\">&#40;<\/span> <span style=\"color: #000088;\">$this<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #0000ff;\">&quot;this&quot;<\/span> <span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nbw_trace2<span style=\"color: #009900;\">&#40;<\/span> <span style=\"color: #000088;\">$that<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #0000ff;\">&quot;that&quot;<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #009900; font-weight: bold;\">false<\/span> <span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\nbw_backtrace<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\ngobang<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n<span style=\"color: #009900;\">&#125;<\/span><br \/>\ncrash<span style=\"color: #009900;\">&#40;<\/span><span style=\"color: #009900;\">&#41;<\/span><span style=\"color: #339933;\">;<\/span><br \/>\n&nbsp;<\/code><\/div>\n<p><!-- \/wp:shortcode --><\/p>\n<p><!-- wp:paragraph --><\/p>\n<p>It&#8217;s good when you want to demonstrate that your code IS being run.<br \/>Use this function even more sparingly than bw_backtrace().<\/p>\n<p><!-- \/wp:paragraph --><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1148,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"letters":[511],"class_list":{"0":"post-40210","1":"page","2":"type-page","3":"status-publish","5":"letters-t","6":"entry"},"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Trace APIs - [oik] plugins.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Trace APIs - [oik] plugins.com\" \/>\n<meta property=\"og:description\" content=\"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 &quot;live&quot;.  During development of the oik plugins, Bobbing&nbsp;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.   bw_trace2( $value=null, $text=null, $show_args=true, $trace_level=BW_TRACE_ALWAYS ); &nbsp;  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 &quot;2&quot; thenthe output that you see in the trace log will be similar to this:  wp-contentpluginsoikoik-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.   bw_backtrace(); &nbsp;  bw_gobang() - Go Bang!  Or whatever you want it to be, so long as it doesn&#039;t exist.We use this mythical function to get a fatal error.   if &#040; $this != $that &#041; &#123; bw_trace2&#040; $this, &quot;this&quot; &#041;; bw_trace2&#040; $that, &quot;that&quot;, false &#041;; bw_backtrace&#040;&#041;; gobang&#040;&#041;; &#125; crash&#040;&#041;; &nbsp;  It&#039;s good when you want to demonstrate that your code IS being run.Use this function even more sparingly than bw_backtrace().\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/\" \/>\n<meta property=\"og:site_name\" content=\"[oik] plugins.com\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-01T16:26:30+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/\",\"url\":\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/\",\"name\":\"Trace APIs - [oik] plugins.com\",\"isPartOf\":{\"@id\":\"https:\/\/www.oik-plugins.com\/#website\"},\"datePublished\":\"2019-12-04T12:04:24+00:00\",\"dateModified\":\"2020-12-01T16:26:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"WordPress plugins from oik-plugins\",\"item\":\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FREE oik plugins\",\"item\":\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"oik-bwtrace &#8211; debug trace for WordPress\",\"item\":\"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Trace APIs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.oik-plugins.com\/#website\",\"url\":\"https:\/\/www.oik-plugins.com\/\",\"name\":\"[oik] plugins.com\",\"description\":\"WordPress plugins and themes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.oik-plugins.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Trace APIs - [oik] plugins.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/","og_locale":"en_US","og_type":"article","og_title":"Trace APIs - [oik] plugins.com","og_description":"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&nbsp;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.   bw_trace2( $value=null, $text=null, $show_args=true, $trace_level=BW_TRACE_ALWAYS ); &nbsp;  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\" thenthe output that you see in the trace log will be similar to this:  wp-contentpluginsoikoik-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.   bw_backtrace(); &nbsp;  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 &#40; $this != $that &#41; &#123; bw_trace2&#40; $this, &quot;this&quot; &#41;; bw_trace2&#40; $that, &quot;that&quot;, false &#41;; bw_backtrace&#40;&#41;; gobang&#40;&#41;; &#125; crash&#40;&#41;; &nbsp;  It's good when you want to demonstrate that your code IS being run.Use this function even more sparingly than bw_backtrace().","og_url":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/","og_site_name":"[oik] plugins.com","article_modified_time":"2020-12-01T16:26:30+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/","url":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/","name":"Trace APIs - [oik] plugins.com","isPartOf":{"@id":"https:\/\/www.oik-plugins.com\/#website"},"datePublished":"2019-12-04T12:04:24+00:00","dateModified":"2020-12-01T16:26:30+00:00","breadcrumb":{"@id":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/trace-apis\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"WordPress plugins from oik-plugins","item":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/"},{"@type":"ListItem","position":2,"name":"FREE oik plugins","item":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/"},{"@type":"ListItem","position":3,"name":"oik-bwtrace &#8211; debug trace for WordPress","item":"https:\/\/www.oik-plugins.com\/wordpress-plugins-from-oik-plugins\/free-oik-plugins\/oik-trace-plugin\/"},{"@type":"ListItem","position":4,"name":"Trace APIs"}]},{"@type":"WebSite","@id":"https:\/\/www.oik-plugins.com\/#website","url":"https:\/\/www.oik-plugins.com\/","name":"[oik] plugins.com","description":"WordPress plugins and themes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.oik-plugins.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/pages\/40210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/comments?post=40210"}],"version-history":[{"count":1,"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/pages\/40210\/revisions"}],"predecessor-version":[{"id":40691,"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/pages\/40210\/revisions\/40691"}],"up":[{"embeddable":true,"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/pages\/1148"}],"wp:attachment":[{"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/media?parent=40210"}],"wp:term":[{"taxonomy":"letters","embeddable":true,"href":"https:\/\/www.oik-plugins.com\/wp-json\/wp\/v2\/letters?post=40210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}