-
-
Save rileyelliott/e314bb00b8dcf2e9181dd069bf335278 to your computer and use it in GitHub Desktop.
Wordpress DECHO
This file contains hidden or 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
| DEBUG_URL=whatever.test |
This file contains hidden or 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
| div.DECHO { | |
| background: #F6F2CD; | |
| border: { | |
| bottom: 2px solid red; | |
| top: 2px solid red; | |
| } | |
| font: { | |
| family: Courier; | |
| size: 12px; | |
| } | |
| h3 { | |
| font: { | |
| size: 14px; | |
| } | |
| max-width: 1300px; | |
| margin: 0 auto; | |
| text-transform: none; | |
| } | |
| pre { | |
| margin: 0 auto; | |
| overflow: auto; | |
| max-width: 1300px; | |
| width: 100%; | |
| } | |
| } |
This file contains hidden or 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 | |
| function DECHO($var) { | |
| $current_user = wp_get_current_user(); | |
| if (user_can($current_user, 'administrator') || $_SERVER['SERVER_NAME'] == getenv('DEBUG_URL')) { | |
| $bt = debug_backtrace(); | |
| $caller = array_shift($bt); | |
| add_action('wp_footer', function () use ($var, $caller) { | |
| echo '<div class="DECHO"><h3>Line: ' . $caller['line'] . '<br />File: ' . $caller['file'] . '</h3><pre>' . print_r($var, | |
| true) . '</pre></div>'; | |
| }); | |
| } | |
| } | |
| function ADECHO($var) { | |
| $current_user = wp_get_current_user(); | |
| if (user_can($current_user, 'administrator')) { | |
| $bt = debug_backtrace(); | |
| $caller = array_shift($bt); | |
| add_action('admin_footer', function () use ($var, $caller) { | |
| echo '<div style="margin-left: 170px;" class="DECHO"><h3>Line: ' . $caller['line'] . '<br />File: ' . $caller['file'] . '</h3><pre>' . print_r($var, | |
| true) . '</pre></div>'; | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment