Skip to content

Instantly share code, notes, and snippets.

@nektobit
Created September 12, 2017 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nektobit/2f999d29637c4bbf0024af30bd22f985 to your computer and use it in GitHub Desktop.
Save nektobit/2f999d29637c4bbf0024af30bd22f985 to your computer and use it in GitHub Desktop.
Best WP test function
<?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