你不能直接把它挂起来wp.Uploader
不会暴露,但可以使用init()
要挂接其内部pluploader实例,请执行以下操作:
add_action( \'admin_print_footer_scripts\', function () {
?>
<script type="text/javascript">
(function ($) {
if (typeof wp.Uploader === \'function\') {
$.extend( wp.Uploader.prototype, {
init : function() { // plupload \'PostInit\'
this.uploader.bind(\'BeforeUpload\', function(file) {
console.log(\'BeforeUpload file=%o\', file);
});
},
success : function( file_attachment ) { // plupload \'FileUploaded\'
console.log( file_attachment );
}
});
}
})(jQuery);
</script>
<?php
}, 100 );