我想链接我的插件到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画廊时,它不会触发。
发布于 2017-10-28 09:16:26
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 );因为,NextGen操作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.jpghttps://stackoverflow.com/questions/46987147
复制相似问题