wp-plupload.jsのこの行は、アップローダーキューが完了するとリセットされることを示しています。だからあなたはこれを行うことができます:
wp.Uploader.queue.on('reset', function() {
alert('Upload Complete!');
});
私はそれをテストしました、そしてそれはWP3.5サイトで動作します。
したがって、これは、「新しいメディアのアップロード」ページの通常のアップローダーと「メディアの挿入」ダイアログの新しいpluploadアップローダーの両方のサポートを含む完全なバージョンです。
:という名前のJavaScriptファイルを作成し、フォルダーまたはテンプレートディレクトリ内の任意の場所wp-admin-extender.js
に保存します。/custom/js/
// Hack for "Upload New Media" Page (old uploader)
// Overriding the uploadSuccess function:
if (typeof uploadSuccess !== 'undefined') {
// First backup the function into a new variable.
var uploadSuccess_original = uploadSuccess;
// The original uploadSuccess function with has two arguments: fileObj, serverData
// So we globally declare and override the function with two arguments (argument names shouldn't matter)
uploadSuccess = function(fileObj, serverData)
{
// Fire the original procedure with the same arguments
uploadSuccess_original(fileObj, serverData);
// Execute whatever you want here:
alert('Upload Complete!');
}
}
// Hack for "Insert Media" Dialog (new plupload uploader)
// Hooking on the uploader queue (on reset):
if (typeof wp.Uploader !== 'undefined' && typeof wp.Uploader.queue !== 'undefined') {
wp.Uploader.queue.on('reset', function() {
alert('Upload Complete!');
});
}
そして最後に; これをテーマのfunctions.phpに追加して、WPAdminでこの機能を取得します。
//You can also use other techniques to add/register the script for WP Admin.
function extend_admin_js() {
wp_enqueue_script('wp-admin-extender.js', get_template_directory_uri().'/custom/js/wp-admin-extender.js', array('media-upload', 'swfupload', 'plupload'), false, true);
}
add_action('admin_enqueue_scripts', 'extend_admin_js');
これは正当な解決策ではないかもしれませんが、少なくとも回避策です。