I'm working on my first Wordpress plugin and am working on my first Custom Post Type. I'm looking to provide some debug output so I can see what kind of data I have to work with.
I have the following code (some snipped for size):
class MyPlugin_Admin {
... SNIP ...
private function __construct() {
... SNIP ...
add_filter( 'wp_insert_post_data', array($this, 'adjust_cpt_data'), 10, 2);
}
public function adjust_cpt_data($data, $postarr) {
var_dump($data);
echo "###########################################";
echo "###########################################";
echo "###########################################";
echo "###########################################";
echo "###########################################";
echo "###########################################";
echo "###########################################";
echo "###########################################";
echo "###########################################";
echo "###########################################";
echo "###########################################";
echo "###########################################";
//d($data);
//dd($postarr);
return $data;
}
... SNIP ...
}
I've tried using all kinds of different outputs. The d() and dd() functions are from Debug Bar and Kint Debugger. They don't work either. If I add some debugging code right under add_filter() that works properly, but not inside adjust_cpt_data(). There is nothing I can do in this function to output data to the screen.
I have been able to verify that this code is running, because if I remove the "return $data;" line, the custom post data does not get updated properly, it just refreshes with the old data.
Have anyone provide any insight on why this is and how I can print some debugging output to the screen.
As a side note, I realize I can get the contents of $data and $postarr by looking at the WP Codex, but I will inevitably run into this issue again when I need to debug my own code.
die;after yourvar_dump.