Created
March 27, 2013 01:21
-
-
Save turtlepod/5250802 to your computer and use it in GitHub Desktop.
my debug mu-plugin. only use this on localhost.
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
<?php | |
/** | |
* Plugin Name: Debug-ing | |
* Plugin URI: http://shellcreeper.com/ | |
* Description: just for debug on localhost. | |
* Version: 0.1.0 | |
* Author: David Chandra Purnama | |
* Author URI: http://shellcreeper.com/ | |
*/ | |
//add_action('admin_footer','capsule_print_data'); | |
//add_action('wp_footer','capsule_print_data'); | |
/* data to display */ | |
function capsule_print_data(){ | |
$testing = WP_CONTENT_DIR; | |
ccdd( $testing, 'WP_CONTENT_DIR' ); | |
} | |
//add_action( 'admin_notices', 'capsule_print_notice_admin_pagehook' ); | |
/** | |
* Print Admin Hook | |
*/ | |
function capsule_print_notice_admin_pagehook(){ | |
global $hook_suffix, $pagenow; | |
if( ! current_user_can( 'manage_options') ) return; | |
?> | |
<div class="error"> | |
<p>$hook_suffix: <code><?php echo $hook_suffix; ?></code> $pagenow: <code><?php echo $pagenow; ?></code> </p> | |
</div> | |
<?php | |
} | |
/** | |
* Preety Debug Data | |
* @link http://chrisbratlien.com/prettier-php-debug-messages-continued/ | |
*/ | |
function ccdd( $obj, $label = '' ) { | |
$data = json_encode(print_r($obj,true)); | |
?> | |
<style type="text/css"> | |
#bsdLogger { | |
position: inherit; | |
bottom:0; | |
border: 3px solid #ffa601; | |
padding: 6px; | |
background: white; | |
color: #444; | |
z-index: 999; | |
font-size: 1.25em; | |
width: 980px; | |
overflow: scroll; | |
margin: 50px auto 0 auto; | |
} | |
</style> | |
<script type="text/javascript"> | |
var doStuff = function(){ | |
var obj = <?php echo $data; ?>; | |
var logger = document.getElementById('bsdLogger'); | |
if (!logger) { | |
logger = document.createElement('div'); | |
logger.id = 'bsdLogger'; | |
document.body.appendChild(logger); | |
} | |
////console.log(obj); | |
var pre = document.createElement('pre'); | |
var h2 = document.createElement('h2'); | |
pre.innerHTML = obj; | |
h2.innerHTML = '<?php echo addslashes($label); ?>'; | |
logger.appendChild(h2); | |
logger.appendChild(pre); | |
}; | |
window.addEventListener ("DOMContentLoaded", doStuff, false); | |
</script> | |
<?php | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment