I am working on a plugin to ajaxify commens as wpmu-plugin. It's almost done, with a weird little problem remaining.
I added a new hook in wp_die() to catch error messages. I added it this way:
1244: do_action('wp_abort', $message);
(line 1244 is right after $message is processed)
Good so far. So I hooked my function on:
add_action('wp_abort', 'ajax_comments_send');
The function, which doesn't do much more than this:
function ajax_comments_send () {
$passed = func_get_arg();
$comment = @get_comment($passed);
if (!is_object($comment)) {
header('HTTP/1.0 406 Not Acceptable');
die($passed);
}
// code for sending the comment on success
The problem is: Whatever I do, the $message isn't passed to ajax_comments_send. I tried to add the die($passed); as first statement, but it doesn't output anything.
Furthermore I digged into the code and did a little debugging. My results:
do_action()is being executed as expected- in plugin.php,
do_action(), the parameter is there and is being passed tocall_user_func_array()correctly ajax_comments_sendworks, the correct header is being sentajax_comments_sendworks, on success the comment is successfully being transmitted
Further investigation showed that I also can't call the function directly in do_action:
if ($tag == 'wp_abort') {
ajax_comments_send('test');
}
After a sleepless night I'm left with a big what the heck?