WordPress:第二个参数的数据类型错误?
昨天升级wordpress后出现这个错误。它指向我的插件之一:
警告:in_array() [function.in-array]:数据类型错误 对于第二个参数 /home/healt134/public_html/wp-content/plugins/video-thumbnails/video-thumbnails.php 402行
警告:无法修改标头信息 - 标头已发送
(输出开始于 /home/healt134/public_html/wp-content/plugins/video-thumbnails/video-thumbnails.php:402) 在 /home/healt134/public_html/wp-includes/pluggable.php 上线897
我查看了 402 中的代码(用星号标记),但我没有看到那里有问题或多余的空白。有人知道我可以做什么来阻止这个错误吗?
function save_video_thumbnail( $post ){
$post_type = get_post_type( $post->ID );
$video_thumbnails_post_types = get_option('video_thumbnails_post_types');
*** if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
return null;
} else {
// Check that Video Thumbnails are enabled for current post type
if (in_array($post_type, $video_thumbnails_post_types) OR $post_type == $video_thumbnails_post_types) {
get_video_thumbnail($post->ID);
} else {
return null;
}
}
}
I got this error yesterday after upgrading wordpress. It's pointing to one of my plugins:
Warning: in_array()
[function.in-array]: Wrong datatype
for second argument in
/home/healt134/public_html/wp-content/plugins/video-thumbnails/video-thumbnails.php
on line 402Warning: Cannot modify header information - headers already sent by
(output started at
/home/healt134/public_html/wp-content/plugins/video-thumbnails/video-thumbnails.php:402)
in
/home/healt134/public_html/wp-includes/pluggable.php
on line 897
I looked at the code in 402 (marked with asterisks) but I don't see a problem or excess white-space there. Anyone know what I might be able to do to stop this error?
function save_video_thumbnail( $post ){
$post_type = get_post_type( $post->ID );
$video_thumbnails_post_types = get_option('video_thumbnails_post_types');
*** if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
return null;
} else {
// Check that Video Thumbnails are enabled for current post type
if (in_array($post_type, $video_thumbnails_post_types) OR $post_type == $video_thumbnails_post_types) {
get_video_thumbnail($post->ID);
} else {
return null;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你已经偏离了几行,尝试降低 4 行。我的猜测是
$video_thumbnails_post_types
不是一个数组。从该
if
语句中的第二个条件来看,$video_thumbnails_post_types
可能是一个标量(字符串、整数等)。如果你愿意的话,将代码修改为I think you're off by a couple of lines there, try 4 lines lower. My guess is
$video_thumbnails_post_types
is not an array.From the second condition in that
if
statement, it looks like$video_thumbnails_post_types
may be a scalar (string, int, etc). If you're up to it, modify the code to be