新搭建WordPress站点出现JQuery Widget系列错误求助
WordPress 全新站点 jQuery/JQuery UI Widget 系列错误排查与解决
我搭建了一个纯净版WordPress站点(无插件、无第三方主题,仅官方原版程序),但未开始自定义就遇到一系列jQuery/JQuery UI相关Widget错误,导致插件页面无法正常显示、手动安装插件后无法删除等问题。
错误信息
Uncaught TypeError: o.widget is not a function at mouse.min.js?ver=1.13.2:11:163 at mouse.min.js?ver=1.13.2:11:84 at mouse.min.js?ver=1.13.2:11:94 draggable.min.js?ver=1.13.2:11 Uncaught TypeError: P.widget is not a function at draggable.min.js?ver=1.13.2:11:135 at draggable.min.js?ver=1.13.2:11:103 at draggable.min.js?ver=1.13.2:11:113 slider.min.js?ver=1.13.2:11 Uncaught TypeError: r.widget is not a function at slider.min.js?ver=1.13.2:11:135 at slider.min.js?ver=1.13.2:11:103 at slider.min.js?ver=1.13.2:11:113 iris.min.js?ver=1.1.1:5 Uncaught TypeError: a.widget is not a function at iris.min.js?ver=1.1.1:5:16724 at iris.min.js?ver=1.1.1:5:16808 color-picker.min.js?ver=6.3.1:2 Uncaught TypeError: i.widget is not a function at color-picker.min.js?ver=6.3.1:2:3449 at color-picker.min.js?ver=6.3.1:2:3478 accordion.min.js?ver=1.13.2:11 Uncaught TypeError: h.widget is not a function at accordion.min.js?ver=1.13.2:11:125 at accordion.min.js?ver=1.13.2:11:93 at accordion.min.js?ver=1.13.2:11:103 resizable.min.js?ver=1.13.2:11 Uncaught TypeError: z.widget is not a function at resizable.min.js?ver=1.13.2:11:135 at resizable.min.js?ver=1.13.2:11:103 at resizable.min.js?ver=1.13.2:11:113 controlgroup.min.js?ver=1.13.2:9 Uncaught TypeError: r.widget is not a function at controlgroup.min.js?ver=1.13.2:9:165 at controlgroup.min.js?ver=1.13.2:9:95 at controlgroup.min.js?ver=1.13.2:9:105 checkboxradio.min.js?ver=1.13.2:9 Uncaught TypeError: t.widget is not a function at checkboxradio.min.js?ver=1.13.2:9:140 at checkboxradio.min.js?ver=1.13.2:9:95 at checkboxradio.min.js?ver=1.13.2:9:105 button.min.js?ver=1.13.2:11 Uncaught TypeError: o.widget is not a function at button.min.js?ver=1.13.2:11:633 at button.min.js?ver=1.13.2:11:93 at button.min.js?ver=1.13.2:11:103 dialog.min.js?ver=1.13.2:11 Uncaught TypeError: l.widget is not a function at dialog.min.js?ver=1.13.2:11:187 at dialog.min.js?ver=1.13.2:11:155 at dialog.min.js?ver=1.13.2:11:165 menu.min.js?ver=1.13.2:11 Uncaught TypeError: a.widget is not a function at menu.min.js?ver=1.13.2:11:138 at menu.min.js?ver=1.13.2:11:106 at menu.min.js?ver=1.13.2:11:116 autocomplete.min.js?ver=1.13.2:11 Uncaught TypeError: o.widget is not a function at autocomplete.min.js?ver=1.13.2:11:147 at autocomplete.min.js?ver=1.13.2:11:115 at autocomplete.min.js?ver=1.13.2:11:125 sortable.min.js?ver=1.13.2:11 Uncaught TypeError: u.widget is not a function at sortable.min.js?ver=1.13.2:11:135 at sortable.min.js?ver=1.13.2:11:103 at sortable.min.js?ver=1.13.2:11:113 droppable.min.js?ver=1.13.2:11 Uncaught TypeError: a.widget is not a function at droppable.min.js?ver=1.13.2:11:186 at droppable.min.js?ver=1.13.2:11:117 at droppable.min.js?ver=1.13.2:11:127 tabs.min.js?ver=1.13.2:11 Uncaught TypeError: l.widget is not a function at tabs.min.js?ver=1.13.2:11:125 at tabs.min.js?ver=1.13.2:11:93 at tabs.min.js?ver=1.13.2:11:103 wpdialog.min.js?ver=6.3.1:2 Uncaught TypeError: e.widget is not a function at wpdialog.min.js?ver=6.3.1:2:16 at wpdialog.min.js?ver=6.3.1:2:229 updates.min.js?ver=6.3.1:2 Uncaught TypeError: Cannot read properties of undefined (reading 'aysDeleteUninstall') at HTMLAnchorElement.<anonymous> (updates.min.js?ver=6.3.1:2:28397) at HTMLFormElement.dispatch (load-scripts.php?c=1&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.3.1:2:39997) at v.handle (load-scripts.php?c=1&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,wp-polyfill-inert,regenerator-runtime,wp-polyfill,wp-hooks&ver=6.3.1:2:37968)
问题细节
- 插件页面无法正常显示,只能手动上传安装插件
- 删除手动安装的插件时触发最后一条
aysDeleteUninstall相关错误
已尝试的无效方案
- ❌ 重新安装纯净版WordPress
- ❌ 克隆正常运行的站点至当前域名(原站点无此问题,克隆后错误依旧)
- ❌ 在
functions.php中手动注册jQuery和jQuery UI脚本 - ❌ 联系服务器支持排查账户(未发现异常)
- ❌ 重启本地网络
- ❌ 清除服务器端、本地、浏览器所有缓存
- ❌ 安装控制jQuery/jQuery UI版本的插件
- ❌ 安装jQuery UI Widgets插件
- ❌ 在后台手动添加jQuery/jQuery UI脚本
- ✅ 清除Cloudflare缓存(无效果)
解决建议
1. 检查jQuery UI Widget核心文件是否缺失/损坏
WordPress官方包中wp-includes/js/jquery/ui/目录下应包含widget.min.js文件,这是所有UI组件依赖的核心:
- 通过FTP或文件管理器查看该文件是否存在,若缺失,从官方WordPress安装包中提取对应版本的文件上传
- 若文件存在,对比文件哈希值与官方包一致,排除文件损坏问题
2. 排查load-scripts.php的脚本加载顺序
错误中显示load-scripts.php加载了jquery-core但未正确加载jquery-ui-widget,可能是脚本加载逻辑被干扰:
- 临时禁用Cloudflare的
Auto Minify功能,避免JS文件被错误合并 - 检查服务器端是否有自定义的
functions.php或mu-plugin修改了脚本加载优先级 - 尝试在
wp-config.php中添加define('SCRIPT_DEBUG', true);开启调试模式,查看未压缩的脚本错误,定位具体加载问题
3. 服务器环境与PHP配置检查
- 检查PHP版本是否符合WordPress 6.3.1的要求(推荐PHP 7.4+)
- 查看服务器的
open_basedir配置,确保WordPress能正常读取wp-includes目录下的JS文件 - 检查服务器的文件权限,
wp-includes/js/目录及子文件权限应设置为755,文件权限为644
4. 手动修复脚本依赖关系
在主题的functions.php中添加以下代码,强制确保jquery-ui-widget在所有UI组件前加载:
function fix_jquery_ui_dependencies() { wp_deregister_script('jquery-ui-widget'); wp_register_script('jquery-ui-widget', includes_url('js/jquery/ui/widget.min.js'), array('jquery'), '1.13.2', true); // 重新注册所有依赖widget的UI组件 $ui_components = array('mouse', 'draggable', 'slider', 'accordion', 'resizable', 'controlgroup', 'checkboxradio', 'button', 'dialog', 'menu', 'autocomplete', 'sortable', 'droppable', 'tabs'); foreach ($ui_components as $component) { wp_deregister_script('jquery-ui-' . $component); wp_register_script('jquery-ui-' . $component, includes_url("js/jquery/ui/{$component}.min.js"), array('jquery-ui-widget'), '1.13.2', true); } } add_action('wp_enqueue_scripts', 'fix_jquery_ui_dependencies', 999); add_action('admin_enqueue_scripts', 'fix_jquery_ui_dependencies', 999);
5. 排查CDN或服务器缓存的深层问题
- 若使用Cloudflare,开启
Development Mode后再次测试,避免缓存的旧JS文件干扰 - 检查服务器端的OPcache或其他PHP缓存,清空后重启PHP服务
- 尝试切换服务器的PHP运行模式(如从CGI切换到FPM),排除运行模式导致的文件读取异常
内容的提问来源于stack exchange,提问作者Knox
相关产品推荐
相关产品推荐

