{"id":50672,"date":"2011-03-02T08:00:00","date_gmt":"2011-03-02T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/debug-bar-extender\/"},"modified":"2011-09-02T21:06:00","modified_gmt":"2011-09-02T21:06:00","slug":"debug-bar-extender","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/debug-bar-extender\/","title":{"rendered":"Debug-Bar-Extender"},"content":{"rendered":"<p>This plugins adds more features to the debug-bar and is mainly aimed at developers who like to debug their code or want to measure runtimes to find glitches in their code.<br \/>\nIt also allows lookup of variables by adding simple code snippets in your source.<\/p>\n<p>Please note that this plugin should be used solely for debugging or on a development environment and is not intended for use in a production site.<\/p>\n<h3>Requirements<\/h3>\n<p>This plugin requires <a href=\"https:\/\/wordpress.org\/extend\/plugins\/debug-bar\" rel=\"ugc\">the debug-bar plugin >0.5<\/a> and a developers\u2019 brain to work correctly.<\/p>\n<h3>Usage<\/h3>\n<h4>Usage example to debug the loop of a theme<\/h4>\n<p>Add your checkpoints in the index.php or any other template file as shown below.<\/p>\n<pre><code><?php if (have_posts()) : ?>\n\n<?php Debug_Bar_Extender::instance()->checkpoint('loop start'); ?>\n\n<?php while (have_posts()) : the_post(); ?>\n\n<?php Debug_Bar_Extender::instance()->trace_var( $post ); ?>\n\n<?php Debug_Bar_Extender::instance()->checkpoint('loop1'); ?>\n\n<div <?php post_class() ?> id=\"post-<?php the_ID(); ?>\">\n<?php \/\/before_post(); ?>\n<h2><a href=\"<?php the_permalink() ?>\" rel=\"bookmark\" title=\"<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>\"><?php the_title(); ?><\/a><\/h2>\n<small><?php the_time(get_option('date_format')) ?> by <?php the_author() ?><\/small>\n<div class=\"entry\">\n<?php the_content(__('Read the rest of this entry &raquo;', 'kubrick')); ?>\n<\/div>\n<p class=\"postmetadata\"><?php the_tags(__('Tags:', 'kubrick') . ' ', ', ', '<br \/>'); ?> <?php printf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?php edit_post_link(__('Edit', 'kubrick'), '', ' | '); ?> <?php comments_popup_link(__('No Comments \u00bb', 'kubrick'), __('1 Comment \u00bb', 'kubrick'), __('% Comments \u00bb', 'kubrick')); ?><\/p>\n<?php after_post(); ?>\n<\/div>\n\n<?php Debug_Bar_Extender::instance()->checkpoint('loop2'); ?>\n\n<?php endwhile; ?>\n\n<?php Debug_Bar_Extender::instance()->checkpoint('loop end'); ?>\n\n<div class=\"navigation\">\n<div class=\"alignleft\"><?php next_posts_link(__('&laquo; Older Entries', 'kubrick')) ?><\/div>\n<div class=\"alignright\"><?php previous_posts_link(__('Newer Entries &raquo;', 'kubrick')) ?><\/div>\n<\/div>\n<?php else : ?>\n<\/code><\/pre>\n<h3>Advanced usage<\/h3>\n<p>Looking at the source of the debug-bar-extender.php you will notice that there are various filters to control the default settings. This is useful when you are working on a multisite install and want to use the debug bar without having to adjust the settings every time. Here\u2019s an example of how settings enforced by a php file in mu-plugins\/ could look like<\/p>\n<pre><code>add_filter( 'debugbarextender_default_settings', 'my_debug_bar_extender_settings' );\n\/\/ enforce debug bar settings\nfunction my_debug_bar_extender_settings( $default_settings ) {\n    $default_settings = array(\n            'enable_profiler'               => 1,\n            'enable_variable_lookup'        => 1,\n            'track_default_vars'            => 0,\n            'add_default_checkpoints'       => 1,\n            'savequeries_debugmode_enable'  => 1,\n            'use_error_log'                 => 0,\n            'allow_url_settings'            => 1,\n            'enable_admin_bar_menu'         => 1,\n    );\n    return $default_settings;\n}\n\nadd_filter( 'debugbarextender_default_checkpoint_actions', 'my_debug_bar_extender_checkpoints' );\n\/\/ initiate some default checkpoints\nfunction my_debug_bar_extender_checkpoints( $default_checkpoints ) {\n    $default_checkpoints = array(\n                    'muplugins_loaded',\n                    'wp_head',\n                    'wp_footer',\n                    'loop_start',\n                    'loop_end',\n                    'shutdown',\n    );\n    return $default_checkpoints;\n}\n<\/code><\/pre>\n<h3>Wishlist<\/h3>\n<p>This is a work in progress, so feel free to pass by on <a href=\"http:\/\/hitchhackerguide.com\/wordpress-plugins\/debug-bar-extender\/\" rel=\"nofollow ugc\">our plugin page<\/a> and leave us<br \/>\nyour suggestions in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Extends the debug-bar plugin with additional tabs to measure runtimes between checkpoints and lookup variable content.<\/p>\n","protected":false},"author":65,"featured_media":262946,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Debug-Bar-Extender - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"Extends the debug-bar plugin with additional tabs to measure runtimes between checkpoints and lookup variable content."},"footnotes":""},"categories":[1],"tags":[7,9123,282],"class_list":["post-50672","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-debug","tag-debug-bar","tag-development"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/50672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=50672"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/50672\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/262946"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=50672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=50672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=50672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}