內容簡介
當食用雞遇到危險時,牠會把頭埋在沙子裡。Ostrichcize 讓外掛或佈景主題的開發人員也能夠像食用雞一樣把頭埋在沙子裡,關閉特定外掛或目前佈景主題的錯誤報告。
如果您曾經安裝過一個外掛,或在一個有外掛會不斷彈出錯誤和注意事項的網站上工作過,但沒有時間去處理問題,您可以使用此外掛關閉這些注意事項。只需要過濾外掛,您就可以將不顯示任何注意事項的外掛添加到列表中。
要將它添加到列表中,只需簡單地編寫類似以下內容的代碼:
function my_ostrichcized_plugins( $slugs ) {
$slugs[] = 'debug-bar-cron';
return $slugs;
}
function my_pre_my_ostrichcized_plugins() {
add_filter( 'ostrichcized_plugins', 'my_ostrichcized_plugins' );
}
add_action( 'plugins_loaded', 'my_pre_my_ostrichcized_plugins', 1 );
</pre>
請注意,在執行任何有問題的代碼之前必須添加過濾器,以便重新定義錯誤報告函數,使其在首次調用之前啟用。這意味著在大多數情況下,此代碼需要運行為外掛而非佈景主題。
要關閉佈景主題的 PHP 錯誤報告,請運行:
function my_ostrichcize_theme() {
add_filter( 'ostrichcize_theme', '__return_true' );
}
add_action( 'plugins_loaded', 'my_ostrichcize_theme', 1 );
</pre>
感謝 Jeremy Felt (@jeremyfelt) 幫助命名這個外掛!
外掛標籤
開發者團隊
原文外掛簡介
At the first sign of trouble, an ostrich buries its head in the sand. Ostrichcize allows a plugin or theme developer to
bury his or her head in the sand by turning off error reporting for select plugins or the current theme.
If you have ever installed a plugin or worked on a site with a plugin that throws numerous of errors and notices, but do
not have the time to fix the issue, you can turn off those notices with this plugin. By simply filtering the plugin, you
can add to the list of plugins for which no notices will be shown.
To add to this list simply write something like:
function my_ostrichcized_plugins( $slugs ) {
$slugs[] = 'debug-bar-cron';
return $slugs;
}
function my_pre_my_ostrichcized_plugins() {
add_filter( 'ostrichcized_plugins', 'my_ostrichcized_plugins' );
}
add_action( 'plugins_loaded', 'my_pre_my_ostrichcized_plugins', 1 );
Note that the filter must be added before any offending code is run in order to redefine the error reporting function
before it is first called. The means that in most cases, this code will need to run from a plugin and not a theme.
To turn off PHP error reporting for a theme, run:
function my_ostrichcize_theme() {
add_filter( 'ostrichcize_theme', '__return_true' );
}
add_action( 'plugins_loaded', 'my_ostrichcize_theme', 1 );
Thanks to Jeremy Felt (@jeremyfelt) for assistance naming the plugin!
