[wp-trac] [WordPress Trac] #61352: PHP deprecation notice in wp_title()

WordPress Trac noreply at wordpress.org
Sun Nov 2 09:26:25 UTC 2025


#61352: PHP deprecation notice in wp_title()
--------------------------+------------------------
 Reporter:  nexbridge     |       Owner:  joedolson
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  6.9
Component:  Themes        |     Version:  6.5.5
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------

Comment (by TobiasBg):

 Ah, I had overlooked the `null` part of the ticket, and thought that this
 is only about the `''` being passed to `explode()`. Thanks for pointing
 this out!

 Nevertheless, `empty()` is still not ideal, and there are a few nice
 articles about this:
 https://localheinz.com/articles/2023/05/10/avoiding-empty-in-php/
 https://dev.to/klnjmm/never-use-empty-function-in-php-4pb0
 https://www.beberlei.de/post/when_to_use_empty_in_php_i_say_never

 Of course, `empty()` does work here and there are many many places in Core
 where it's used like that, but I think for new code, stricter checks are
 beneficial.

 In this case, instead of my suggestion from above, a check like
 {{{
 if ( ! is_string( $title ) ) {
   $title = '';
 }
 }}}
 (above the `apply_filters` from [61108]) would be worthwhile, I think.
 Then, the `explode()` would always work on a string, and it would return
 the expected output of an array with an empty string.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61352#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list