I'm trying to put the WP Pluploader into a meta box on my posts page - as per Plupload Intergration in a meta-box? and http://www.krishnakantsharma.com/2012/01/image-uploads-on-wordpress-admin-screens-using-jquery-and-new-plupload/
I got it all working as in the example in the second link. However, I want to put it all into a class file. It stops working if I wrap it all into a Class. And it's all because of:
function g_plupload_action()
{
// check ajax noonce
$imgid = $_POST["imgid"];
check_ajax_referer($imgid . 'pluploadan');
// handle file upload
$status = wp_handle_upload($_FILES[$imgid . 'async-upload'], array('test_form' => true, 'action' => 'plupload_action'));
// send the uploaded file url in response
echo $status['url'];
exit;
}
It works if this function is outside the Class and called through:
add_action('wp_ajax_plupload_action', "g_plupload_action");
But inside the Class and called with:
add_action('wp_ajax_plupload_action', array($this, 'g_plupload_action'));
and the return data is 0
.
What do I need to do in function g_plupload_action()
to make it work?