Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: My Whatever Debug Tracer
- Description: In WP_DEBUG mode, find out what plugin or theme file is causing notices.
- */
- ////////////////////////////////////////////////////////
- // You can upload this file as wp-content/mu-plugins/my-whatever-debug-tracer.php
- // and it will automatically activate (see http://codex.wordpress.org/Must_Use_Plugins ),
- // or put it in your theme's functions.php, or use it as a normal plugin.
- ////////////////////////////////////////////////////////
- if (WP_DEBUG) {
- // Set WP_DEBUG true in wp-config.php, otherwise this plugin does nothing.
- // Note, WP_DEBUG can be set like this in wp-config.php, for testing a live site:
- // define('WP_DEBUG', 'your ip number' === @$_SERVER['REMOTE_ADDR']);
- add_action( 'deprecated_argument_run', 'my_whatever_debug_backtrace' );
- add_action( 'doing_it_wrong_run', 'my_whatever_debug_backtrace' );
- }
- if (! function_exists('function my_whatever_debug_backtrace')) {
- ///////////////////////////////////////////////////////
- function my_whatever_debug_backtrace($f) {
- // Another way to do it, suggested by
- // http://wordpress.org/support/topic/notice-wp_deregister_script-was-called-incorrectly
- // would be:
- // throw new Exception("Testing");
- // (It will halt the script).
- // Just print the trace for the first offender, to make the output easier to read.
- if (defined('MY_WHATEVER_DEBUG_DONE')) return;
- define('MY_WHATEVER_DEBUG_DONE', true);
- printf("<pre>my_whatever_debug_backtrace($f)</pre>\n");
- $fvs= debug_backtrace();
- foreach ($fvs as $i=>$fv) {
- // Just print the first line, and the first line referencing wp-content
- $m= is_int(strpos((string)@$fv['file'], 'wp-content'));
- if ($i==0 || $m) {
- printf(
- "<pre>my_whatever_debug_backtrace(%s)[%d]=[%s]</pre>\n",
- $f,
- $i,
- htmlspecialchars(print_r($fv,1))
- );
- if ($m) break;
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement