-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stewart Ritchie
authored and
Stewart Ritchie
committed
Feb 27, 2019
0 parents
commit 3caa4f6
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "pbc/debug-tools", | ||
"description": "WordPress Debugging Tools for PBC projects", | ||
"type": "wordpress-muplugin", | ||
"license": "GPL2", | ||
"authors": [ | ||
{ | ||
"name": "Stewart Ritchie", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
/** | ||
* Plugin Name | ||
* | ||
* @package Powered By Coffee Debug Tools | ||
* @author Stewart Ritchie | ||
* @copyright 2019 Powered By Coffee | ||
* @license GPL-2.0+ | ||
* | ||
* @wordpress-plugin | ||
* Plugin Name: Powered By Coffee Debug Tools | ||
* Plugin URI: https://poweredbycoffee.co.uk | ||
* Description: Description of the plugin. | ||
* Version: 1.0.0 | ||
* Author: stewarty | ||
* Author URI: https://poweredbycoffee.co.uk | ||
* Text Domain: pbc-debug-tools | ||
* License: GPL-2.0+ | ||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt | ||
*/ | ||
|
||
|
||
function pbc_backtrace(){ | ||
|
||
$trace = debug_backtrace(); | ||
|
||
//echo "<pre>"; | ||
//var_dump($trace); | ||
|
||
echo "<table>"; | ||
|
||
foreach($trace as $key => $line){ | ||
|
||
if($line['function'] == "pbc_backtrace"){ | ||
continue; | ||
} | ||
|
||
if(($line['function'] == "do_action") && (($line['class'] == "WP_Hook") )){ | ||
continue; | ||
} | ||
|
||
echo "<tr style='background-color:#f5f5f5;'>"; | ||
echo "<td>"; | ||
echo $line['function']; | ||
if($line['function'] == "do_action"){ | ||
echo " [" . $line['args'][0] . "]"; | ||
} | ||
echo "</td>"; | ||
|
||
echo "<td>"; | ||
echo (isset($line['class']) ? $line['class'] : "" ); | ||
echo "</td>"; | ||
|
||
echo "<td>"; | ||
echo (isset($line['type']) ? $line['type'] : "" ); | ||
echo "</td>"; | ||
|
||
echo "<td>"; | ||
echo (isset($line['file']) ? $line['file'] : "" ); | ||
echo "</td>"; | ||
echo "</tr>"; | ||
} | ||
|
||
echo "</table>"; | ||
|
||
} | ||
|
||
|
||
function pbc_dump($trace){ | ||
echo "<pre>"; | ||
var_dump($trace); | ||
echo "</pre>"; | ||
die(); | ||
} | ||
|
||
function pbc_log($log){ | ||
write_log($log); | ||
} | ||
|
||
|
||
if ( ! function_exists('write_log')) { | ||
function write_log ( $log ) { | ||
if ( is_array( $log ) || is_object( $log ) ) { | ||
error_log( print_r( $log, true ) ); | ||
} else { | ||
error_log( $log ); | ||
} | ||
} | ||
} | ||
|