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

有帮助吗?

解决方案

Looking 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' ),
        )
    );
许可以下: CC-BY-SA归因
scroll top