I am using the following code:
register_setting(
'myplugin_options', //setting group name
'myplugin_options', //option name that will be stored in the database
'myplugin_validate_options'//optional callback function
);
function myplugin_validate_options($input) {
//how can i print $input to the screen or view the output of this function for debugging purpsoses?
}
I just need to know how we can debug our validation callback functions. From what I see they can not be output to the screen so it makes writing correct code inside of them difficult.
Thanks.
The dirty and only way I’ve founded:
When echoing ( echo($var) ) within ‘library’ code (ie. before the page is being built, as in the case here of register_setting) these statements will typically print just after the opening tag in the HTML but will often not show up there. I use PHP’s built-in function error_log() to print whatever I want directly to PHP’s error log. Then I can just open that file (usually php_error.log somewhere) and see the output. Work for you?
Set up xdebug, the only way to do any real debugging! What is your development set-up? Are you running your code from localhost or using vagrant?
none of the above solutions worked for me,
I even tried the debug statements to a file.
A work around which does the job is
add a call to undefined function after all your debug statements, then the out put is printed to the screen.
You can add the
add_settings_error
function like this: