[wordpress插件] Debug-Bar-Extender调试栏扩展器

wordpress 插件 文章 2020-04-14 02:00 489 0 全屏看文

AI助手支持GPT4.0

评分
92
描述

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.

此插件在调试栏中添加了更多功能,主要针对希望调试其代码或希望测量运行时以发现其代码故障的开发人员。

It also allows lookup of variables by adding simple code snippets in your source.

它还可以通过在源代码中添加简单的代码片段来查找变量。

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.

请注意,此插件应仅用于调试或在开发环境中使用,而不打算在生产站点中使用。

Requirements

要求

This plugin requires the debug-bar plugin >0.5 and a developers' brain to work correctly.

此插件需要调试工具插件> 0.5 和开发人员的大脑才能正常工作。

p>

>

Usage

用法

Usage example to debug the loop of a theme

使用示例调试主题循环

Add your checkpoints in the index.php or any other template file as shown below.

将您的检查点添加到index.php或任何其他模板文件中,如下所示。

  <?php if(have_posts()):?>

checkpoint('loop start');

<?php Debug_Bar_Extender :: instance()-> checkpoint('循环开始');

?>

?>

<?php while(have_posts()):the_post();

?>

?>

trace_var( $post );

<?php Debug_Bar_Extender :: instance()-> trace_var($ post);

?>

?>

checkpoint('loop1');

<?php Debug_Bar_Extender :: instance()-> checkpoint('loop1');

?>

?>

id="post-">

id =“ post-<?php the_ID();?>”>

<?php // before_post();

?>

?>

“ rel =” bookmark“ title =” <?php printf(__('永久链接到%s','kubrick'),the_title_attribute('echo =

0')); ?>">

0'));?>“> <?php the_title();

?>

?>

by

<?php the_time(get_option('date_format'))?>通过<?php the_author()?>

<?php the_content(__('阅读本条目的其余部分&raquo;','kubrick'));

?>

?>

<?php the_tags(__('Tags:','kubrick')。'',',','
');

?>

?> <?php printf(__('张贴在%s','kubrick'),get_the_category_list(','));

?> |

?> |

<?php edit_post_link(__('Edit','kubrick'),``,'|');

?>

?> <?php comments_popup_link(__('No Comments»','kubrick'),__('1 Comment»','kubrick'),__('%Comments»','kubrick'));;

?>

?>

<?php after_post();

?>

?>

checkpoint('loop2');

<?php Debug_Bar_Extender :: instance()-> checkpoint('loop2');

?>

?>

<?php结束;

?>

?>

checkpoint('loop end');

<?php Debug_Bar_Extender :: instance()-> checkpoint('loop end');

?>

?>

Advanced usage

高级用法

Looking at the source of the debug-bar-extender.php you will notice that there are various filters to control the default settings.

查看debug-bar-extender.php的源代码,您会发现有各种过滤器可以控制默认设置。

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’s an example of how settings enforced by a php file in mu-plugins/ could look like

这是一个示例,说明由mu-plugins /中的php文件执行的设置看起来像

add_filter( 'debugbarextender_default_settings', 'my_debug_bar_extender_settings' );

  add_filter('debugbarextender_default_settings','my_debug_bar_extender_settings');

// enforce debug bar settings

//强制执行调试栏设置

function my_debug_bar_extender_settings( $default_settings ) {    

函数my_debug_bar_extender_settings($ default_settings){    

$default_settings = array(            

$ default_settings =数组(            

'enable_profiler' => 1,            

'enable_profiler'=> 1,            

'enable_variable_lookup' => 1,            

'enable_variable_lookup'=> 1,            

'track_default_vars' => 0,            

'track_default_vars'=> 0,            

'add_default_checkpoints' => 1,            

'add_default_checkpoints'=> 1            

'savequeries_debugmode_enable' => 1,            

'savequeries_debugmode_enable'=> 1,            

'use_error_log' => 0,            

'use_error_log'=> 0,            

'allow_url_settings' => 1,            

'allow_url_settings'=> 1            

'enable_admin_bar_menu' => 1,    

'enable_admin_bar_menu'=> 1    

);    

);    

return $default_settings;

返回$ default_settings;

}

}

add_filter( 'debugbarextender_default_checkpoint_actions', 'my_debug_bar_extender_checkpoints' );

add_filter('debugbarextender_default_checkpoint_actions','my_debug_bar_extender_checkpoints');

// initiate some default checkpoints

//启动一些默认检查点

function my_debug_bar_extender_checkpoints( $default_checkpoints ) {    

函数my_debug_bar_extender_checkpoints($ default_checkpoints){    

$default_checkpoints = array(                    

$ default_checkpoints =数组(                    

'muplugins_loaded',                    

'muplugins_loaded',                    

'wp_head',                    

'wp_head',                    

'wp_footer',                    

'wp_footer',                    

'loop_start',                    

'loop_start',                    

'loop_end',                    

'loop_end',                    

'shutdown',    

'关掉',    

);    

);    

return $default_checkpoints;

返回$ default_checkpoints;

}

}

Wishlist

愿望清单

This is a work in progress, so feel free to pass by on our plugin page

这是一项正在进行的工作,请随时在我们的插件页面上

and leave us

离开我们

your suggestions in the comments.

您在评论中的建议。

下载地址
https://downloads.wordpress.org/plugin/debug-bar-extender.zip
-EOF-

AI助手支持GPT4.0