admin管理员组文章数量:1330564
After years of running fine, I am suddenly getting this dreaded message after updating to 5.42. However it only happens in the Admin:
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
The code at line 3140 of media.php is
if ('attachment' === $object_type || 0 === strpos( $object_type, 'attachment:' ) ) {
It appears that the problem is a custom taxonomy I have. Which is created here in 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' );
When I test for the offending $object_type in media.pho and get a var_dump(), it comes back that $object_type is an array:
'orderby' => 'term_order'
I've tried looking for white space and stray characters in functions.php but I don't see anything.
Any ideas on what next to try? Again, this worked fine for almost a decade until 5.42
After years of running fine, I am suddenly getting this dreaded message after updating to 5.42. However it only happens in the Admin:
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
The code at line 3140 of media.php is
if ('attachment' === $object_type || 0 === strpos( $object_type, 'attachment:' ) ) {
It appears that the problem is a custom taxonomy I have. Which is created here in 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' );
When I test for the offending $object_type in media.pho and get a var_dump(), it comes back that $object_type is an array:
'orderby' => 'term_order'
I've tried looking for white space and stray characters in functions.php but I don't see anything.
Any ideas on what next to try? Again, this worked fine for almost a decade until 5.42
Share Improve this question asked Jul 9, 2020 at 19:42 jchwebdevjchwebdev 7752 gold badges14 silver badges33 bronze badges 1- Worth noting that you're getting 'headers already sent' only because there's that Warning being generated and outputting stuff before anything else. It's not to do with e.g. whitespace – mozboz Commented Jul 9, 2020 at 22:13
1 Answer
Reset to default 2Looking at the docs for register_taxonomy, it takes 3 parameters, the 3rd of which is the arguments, and it looks like in your code you have the arguments in the second parameter. Perhaps this is one of those tricky bugs where this was somehow working in previous versions and it officially shouldn't have been.
If songs is the object, you need to add another parameter for the taxonomy key, e.g.:
register_taxonomy(
'songs_tax',
'songs',
array(
'label' => __( 'Songs_Tax' ),
'sort' => true,
'args' => array( 'orderby' => 'term_order' ),
)
);
本文标签: custom taxonomyHeaders already sent warning in Admin source is mediaphp 3140
版权声明:本文标题:custom taxonomy - Headers already sent warning in Admin source is media.php 3140 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742273635a2444778.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论