WordPress:第二个参数的数据类型错误?

发布于 2024-11-07 02:08:29 字数 1130 浏览 0 评论 0原文

昨天升级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 402

Warning: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-11-14 02:08:29

我认为你已经偏离了几行,尝试降低 4 行。我的猜测是 $video_thumbnails_post_types 不是一个数组。

从该 if 语句中的第二个条件来看,$video_thumbnails_post_types 可能是一个标量(字符串、整数等)。如果你愿意的话,将代码修改为

if (in_array($post_type, (array) $video_thumbnails_post_types)
    || $post_type == $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

if (in_array($post_type, (array) $video_thumbnails_post_types)
    || $post_type == $video_thumbnails_post_types)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文