2017-10-28 48 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