Created
September 12, 2017 05:29
-
-
Save nektobit/2f999d29637c4bbf0024af30bd22f985 to your computer and use it in GitHub Desktop.
Best WP test function
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 | |
/** | |
* Usage: | |
* $something = 'string'; | |
* $something = array('key' => 'value', $something); | |
* do_action('testlog', $something); | |
*/ | |
add_action('testlog', 'do_testlog'); | |
function do_testlog($arg) { | |
if(is_array($arg)) { | |
$arg = print_r($arg, true); | |
} | |
if(is_object($arg)) { | |
$arg = serialize($arg); | |
} | |
file_put_contents( ABSPATH . 'testlog.txt', $arg . PHP_EOL, FILE_APPEND ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment