Javascript Wordpress plupload不是一个函数

Javascript Wordpress plupload不是一个函数,javascript,jquery,wordpress,file,plupload,Javascript,Jquery,Wordpress,File,Plupload,我在控制台中不断收到以下错误 未捕获的TypeError:$(…)。plupload不是函数 我正在尝试设置一个WordPress前端页面,在那里登录的用户可以上传图像 似乎有什么东西阻止了这个脚本。这让我发疯了 它排队了。我有一个函数来验证它是否已加载 function my_detected_scripts() { global $wp_scripts; foreach( $wp_scripts->queue as $handle ) : echo $handle .

我在控制台中不断收到以下错误

未捕获的TypeError:$(…)。plupload不是函数

我正在尝试设置一个WordPress前端页面,在那里登录的用户可以上传图像

似乎有什么东西阻止了这个脚本。这让我发疯了

它排队了。我有一个函数来验证它是否已加载

function my_detected_scripts() {
  global $wp_scripts;
  foreach( $wp_scripts->queue as $handle ) :
    echo $handle . ' <br /> ';
  endforeach;
}

echo my_detected_scripts();
我甚至无法加载通用的基本设置

以下是我粘贴到该页面模板文件中的内容

<h1>jQuery UI Widget</h1>

<p>You can see this example with different themes on the <a href="http://plupload.com/example_jquery_ui.php">www.plupload.com</a> website.</p>

<form id="form" method="post" action="/echo/json">
    <div id="uploader">
        <p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
    </div>
    <br />
    <input type="submit" value="Submit" />
</form>

<script type="text/javascript">
$(document).ready(function() {
    $("#uploader").plupload({
        // General settings
        runtimes: 'html5,flash,silverlight,html4',

        // Fake server response here 
        // url : '../upload.php',
        url: "/echo/json",

        // Maximum file size
        max_file_size: '1000mb',

        // User can upload no more then 20 files in one go (sets multiple_queues to false)
        max_file_count: 20,

        chunk_size: '1mb',

        // Resize images on clientside if we can
        resize : {
            width: 200, 
            height: 200, 
            quality: 90,
            crop: true // crop to exact dimensions
        },

        // Specify what files to browse for
        filters: [
            { title: "Image files", extensions: "jpg,gif,png" },
            { title: "Zip files", extensions:  "zip,avi" }
        ],

        // Rename files by clicking on their titles
        rename: true,

        // Sort files
        sortable: true,

        // Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
        dragdrop: true,

        // Views to activate
        views: {
            list: true,
            thumbs: true, // Show thumbs
            active: 'thumbs'
        },

        // Flash settings
        flash_swf_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/flash/Moxie.cdn.swf',

        // Silverlight settings
        silverlight_xap_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/silverlight/Moxie.cdn.xap'
    });


    // Handle the case when form was submitted before uploading has finished
    $('#form').submit(function(e) {
        // Files in queue upload them first
        if ($('#uploader').plupload('getFiles').length > 0) {

            // When all files are uploaded submit form
            $('#uploader').on('complete', function() {
                $('#form')[0].submit();
            });

            $('#uploader').plupload('start');
        } else {
            alert("You must have at least one file in the queue.");
        }
        return false; // Keep the form from submitting
    });
});
</script>
jqueryui小部件
你可以在网站上看到这个不同主题的例子

您的浏览器不支持Flash、Silverlight或HTML5


$(文档).ready(函数(){ $(“#上传器”).plupload({ //一般设置 运行时:“html5、flash、silverlight、html4”, //这里是假的服务器响应 //url:“../upload.php”, url:“/echo/json”, //最大文件大小 最大文件大小:“1000mb”, //用户一次最多只能上载20个文件(将多个_队列设置为false) 最大文件数:20, 块大小:“1mb”, //如果可以,在客户端调整图像大小 调整大小:{ 宽度:200, 身高:200, 质量:90, 裁剪:真//裁剪到精确尺寸 }, //指定要浏览的文件 过滤器:[ {标题:“图像文件”,扩展名:“jpg,gif,png”}, {标题:“Zip文件”,扩展名:“Zip,avi”} ], //通过单击文件标题重命名文件 重命名:对, //排序文件 可排序:是的, //允许将文件拖放到小部件上(目前只有HTML5支持此功能) 德拉格德罗普:没错, //要激活的视图 观点:{ 列表:正确, 拇指:true,//显示拇指 活动:“拇指” }, //闪光设置 flash_swf_url:'http://rawgithub.com/moxiecode/moxie/master/bin/flash/Moxie.cdn.swf', //Silverlight设置 silverlight_xap_url:'http://rawgithub.com/moxiecode/moxie/master/bin/silverlight/Moxie.cdn.xap' }); //处理在上传完成前提交表单的情况 $('表格')。提交(功能(e){ //队列中的文件首先上载它们 if($('#uploader').plupload('getFiles').length>0){ //上传所有文件后,提交表单 $('#uploader')。在('complete',function()上{ $('#form')[0]。提交(); }); $('上传器').plupload('开始'); }否则{ 警报(“队列中必须至少有一个文件。”); } return false;//阻止表单提交 }); });
我对使用plupload还不熟悉,必须有一些东西是《启动指南》没有提到的。然而,wordpress特有的东西很薄

请让我知道我遗漏了什么,或者我如何才能将其加载?它位于测试服务器上,因此我无法提供URL

我知道里面的一些配置是不正确的,但它仍然应该触发plupload


非常感谢你的帮助

只需将脚本中的所有“$”替换为“jQuery”并进行检查。这不会改变任何内容。仍然收到错误:uncaughttypeerror:$(…)。plupload不是我将此JSFIDLE复制到模板中的函数。它在jsfiddle上工作。模板上没有。回显加载的脚本将plupload显示为排队。这还能是什么?这让我发疯。我还将plupload文件夹从新安装的wp复制到测试服务器中。没有变化。好吧,这里有点奇怪。我取出队列,在标题中手动添加到js和css的链接,然后让它开始工作。这真的很奇怪。有人知道这是为什么吗?绕过正常的WP排队过程并将这些文件硬编码到头文件中似乎有问题。嗯,这些可以改为在页脚中加载吗?我们下一步将对此进行测试。
<h1>jQuery UI Widget</h1>

<p>You can see this example with different themes on the <a href="http://plupload.com/example_jquery_ui.php">www.plupload.com</a> website.</p>

<form id="form" method="post" action="/echo/json">
    <div id="uploader">
        <p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
    </div>
    <br />
    <input type="submit" value="Submit" />
</form>

<script type="text/javascript">
$(document).ready(function() {
    $("#uploader").plupload({
        // General settings
        runtimes: 'html5,flash,silverlight,html4',

        // Fake server response here 
        // url : '../upload.php',
        url: "/echo/json",

        // Maximum file size
        max_file_size: '1000mb',

        // User can upload no more then 20 files in one go (sets multiple_queues to false)
        max_file_count: 20,

        chunk_size: '1mb',

        // Resize images on clientside if we can
        resize : {
            width: 200, 
            height: 200, 
            quality: 90,
            crop: true // crop to exact dimensions
        },

        // Specify what files to browse for
        filters: [
            { title: "Image files", extensions: "jpg,gif,png" },
            { title: "Zip files", extensions:  "zip,avi" }
        ],

        // Rename files by clicking on their titles
        rename: true,

        // Sort files
        sortable: true,

        // Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
        dragdrop: true,

        // Views to activate
        views: {
            list: true,
            thumbs: true, // Show thumbs
            active: 'thumbs'
        },

        // Flash settings
        flash_swf_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/flash/Moxie.cdn.swf',

        // Silverlight settings
        silverlight_xap_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/silverlight/Moxie.cdn.xap'
    });


    // Handle the case when form was submitted before uploading has finished
    $('#form').submit(function(e) {
        // Files in queue upload them first
        if ($('#uploader').plupload('getFiles').length > 0) {

            // When all files are uploaded submit form
            $('#uploader').on('complete', function() {
                $('#form')[0].submit();
            });

            $('#uploader').plupload('start');
        } else {
            alert("You must have at least one file in the queue.");
        }
        return false; // Keep the form from submitting
    });
});
</script>