已在管理源中发送警告的标头为media.php 3140

时间:2020-07-09 作者:jchwebdev

经过多年的良好运行,我在更新到5.42后突然收到了这个可怕的消息。但是,它只在管理员中发生:

Warning: strpos() expects parameter 1 to be string, array given in Warning/home/content/55/html/example/wp-includes/media.php on line 3141

Warning: Cannot modify header information - headers already sent by (output started at /home/content/55/8933555/html/example/wp-includes/media.php:3141) in /home/content/55/8933555/html/example/wp-includes/functions.php on line 6221

Warning: Cannot modify header information - headers already sent by (output started at /home/content/55/8933555/html/example/wp-includes/media.php:3141) in /home/content/55/8933555/html/example/wp-admin/includes/misc.php on line 1282

Warning: Cannot modify header information - headers already sent by (output started at /home/content/55/8933555/html/example/wp-includes/media.php:3141) in /home/content/55/8933555/html/example/wp-admin/admin-header.php on line 9

Warning: Cannot modify header information - headers already sent by (output started at /home/content/55/8933555/html/example/wp-includes/media.php:3141) in /home/content/55/8933555/html/example/wp-includes/option.php on line 961

 Warning: Cannot modify header information - headers already sent by (output started at /home/content/55/8933555/html/example/wp-includes/media.php:3141) in /home/content/55/8933555/html/example/wp-includes/option.php on line 962
介质第3140行的代码。php是

if(\'attachment\'===$对象\\u类型| | 0===strpos($object\\u类型,\'attachment:\')){

问题似乎是我的自定义分类法。这是在functions()中创建的。php

function songs_init() {
    // create a new taxonomy
register_taxonomy(
        \'songs\',
        array(
            \'label\' => __( \'Songs_Tax\' ),
            \'sort\' => true,
            \'args\' => array( \'orderby\' => \'term_order\' ),
)
);
}
add_action( \'init\', \'songs_init\' );
当我在媒体中测试有问题的$object\\u类型时。pho并获取var\\u dump(),返回$object\\u type是一个数组:

\'orderby\' => \'term_order\'
我试着在函数中寻找空白和离群字符。php,但我什么都没看到。

下一步该怎么做?同样,在5.42之前的近十年中,这项技术一直运行良好

1 个回复
最合适的回答,由SO网友:mozboz 整理而成

查看文档register_taxonomy, 它有3个参数,其中第3个是参数,在代码中,第二个参数中似乎有参数。也许这是一个棘手的bug,在以前的版本中,它在某种程度上起到了作用,但官方不应该这样做。

如果对象是songs,则需要为分类键添加另一个参数,例如:

    register_taxonomy(
        \'songs_tax\',
        \'songs\',
        array(
            \'label\' => __( \'Songs_Tax\' ),
            \'sort\' => true,
            \'args\' => array( \'orderby\' => \'term_order\' ),
        )
    );

相关推荐

WP Admin messed up

我已经更新了我的wordpress,一些管理页面被弄乱了,这似乎是CSS问题,我已经删除了缓存,但它没有修复这个问题。我真的不知道这是怎么回事。有办法解决吗?我附上一些例子。例如,如果我去添加新插件,然后按Install Now或More Details,页面会向下滚动并被阻止,只有侧菜单会响应。。。