[英]Warning: in_array() [function.in-array]: Wrong datatype for second argument
I've got this error when I activated one plugin. 激活一个插件时出现此错误。 I'm not a professional programmer, but I have some php experience.
我不是专业程序员,但是我有一些php经验。 Help me please.
请帮帮我。 The error is in the
if ( in_array('template-widget', $widgets)) {
line. 错误在
if ( in_array('template-widget', $widgets)) {
行中。
function ActionWpPrintScripts() {
global $post;
// Check to see if widget is present on page
$sidebars_widgets = wp_get_sidebars_widgets(false);
$widget_loaded = false;
if ( is_array($sidebars_widgets) ) {
foreach ( $sidebars_widgets as $sidebar => $widgets ) {
if ( in_array('template-widget', $widgets)) {
$widget_loaded = true;
}
}
}
}
The function wp_get_sidebars_widgets
is not supposed to be called by plugins, only used internally. wp_get_sidebars_widgets
函数wp_get_sidebars_widgets
由插件调用,而只能在内部使用。 The documentation also states that 该文档还指出
Upgraded list of widgets to version 3 array format when called from the admin .
从管理员调用时,将小部件的列表升级为版本3阵列格式。
So that might be the reason why it does not work in the context you are calling it. 因此,这可能就是为什么它在您调用它的上下文中不起作用的原因。 My suggestion is to try another approach for whatever you are trying to accomplish.
我的建议是针对您要完成的任务尝试另一种方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.