2017-10-28 66 views
0

我想将我的插件链接到nextgen上传。 当用户在上传图片时上传图片时,我希望它也通过我们的插件。我们尝试了不同的挂钩,但都没有工作。任何想法都会很棒。将插件链接到nextgen上传电话

我想这

function my_enqueue($hook) { 
    if ($hook == 'admin.php' || $hook=='wp_ajax_request-nextgen') { 
    //some codes here 
} 
    } 

然后

add_action('wp_ajax_request-nextgen', array(&$this, 'other_media_library_nextgen_ajax_callback'), 9, 2); 

但是,当我们将图像上传到NextGen的画廊

回答

0
add_action('init', function() { 
    if (! isset($_REQUEST[ 'photocrati_ajax' ]) || $_REQUEST['action'] !== 'upload_image') { 
     # not an upload image request so 
     return; 
    } 
    # process upload request here 
}, 9); 

因为,在次世代动作M_Ajax :: serve_ajax_request(其不点火)调用exit()后,您无法在NextGen操作之后运行。如果您需要在NextGen操作之后执行操作,那么您可以先在操作中运行NextGen操作,然后再操作并退出。

add_action('init', function() { 
    if (! isset($_REQUEST[ 'photocrati_ajax' ]) || $_REQUEST['action'] !== 'upload_image') { 
     # not an upload image request so 
     return; 
    } 
    # First do the NextGen action M_Ajax::serve_ajax_request() processing 
    $controller = C_Ajax_Controller::get_instance(); 
    $controller->index_action(); 
    # Now do your image upload processing here 
    # Finally, must exit otherwise NextGen action will be done twice 
    exit; 
}, 9); 

的$ _REQUEST这个样子的

[photocrati_ajax] => 1 
[action] => upload_image 
[gallery_id] => 0 
[gallery_name] => gallery 
[nextgen_upload_image_sec] => 496cc9951b 
[name] => image.jpg