简体   繁体   English

WordPress文件中的双jQuery条目

[英]Double jQuery entry in wordpress file

I have 2 jquery script tags on this page and I am trying to find where they are inserted from. 我在此页面上有2个jquery脚本标签,我试图找到它们的插入位置。 I have located one which comes from header.php, but cannot find the second one. 我找到了一个来自header.php的文件,但是找不到第二个。 Is there a browser developer tool that could help me with this? 有浏览器开发人员工具可以帮助我吗?

A browser developer toolbar will not tell you what WordPress item is asking for another jQuery script. 浏览器开发人员工具栏不会告诉您什么WordPress项目正在要求另一个jQuery脚本。

Often plugins and themes will want to include their own version...and it can cause conflicts. 通常,插件和主题会希望包含其自己的版本...这可能会导致冲突。

The version of jQuery installed with your wordpress version is 1.10.2, and "something" is calling jQuery 1.8.2. 随您的wordpress版本一起安装的jQuery版本是1.10.2,“ something”正在调用jQuery 1.8.2。

You may want to try removing the reference to 1.8.2 from your theme file (header.php) 您可能想要尝试从主题文件(header.php)中删除对1.8.2的引用。

Just try the following mini plugin: 只需尝试以下迷你插件:

<?php
/** Plugin Name: Debug Scripts */
add_action( 'wp_enqueue_scripts', function() {
    var_dump( current_filter(), $GLOBALS['wp_filters'], $GLOBALS['wp_scripts'] );
}, 999 );

This will tell you 这会告诉你

  • The name of the current filter ( wp_enqueue_scripts ) 当前过滤器的名称( wp_enqueue_scripts
  • All registered filters 所有注册的过滤器
  • All registered scripts 所有注册脚本

Then search for your script, search for the callback and then search for the plugin or theme causing it. 然后搜索您的脚本,搜索回调,然后搜索导致它的插件或主题。 You got all the tools. 您拥有所有工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM