[wp-trac] [WordPress Trac] #65408: Code Modernization: Use str_contains() instead of strpos()

WordPress Trac noreply at wordpress.org
Thu Jun 4 12:36:10 UTC 2026


#65408: Code Modernization: Use str_contains() instead of strpos()
------------------------------+-----------------------------
 Reporter:  Soean             |      Owner:  (none)
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  General           |    Version:
 Severity:  normal            |   Keywords:  has-patch
  Focuses:  coding-standards  |
------------------------------+-----------------------------
 `str_contains()` was introduced in PHP 8.0 to perform a case-sensitive
 check indicating if the string to search in (haystack) contains the given
 substring (needle).

 WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of
 WordPress 5.9.

 This change replaces new introduced `false !== strpos( ... )` and `false
 === strpos( ... )`  with `str_contains()` in core files, making the code
 more readable and consistent, as well as better aligned with modern
 development practices.

 Introduced in [[https://core.trac.wordpress.org/changeset/60269|r60269]]
 and [[https://core.trac.wordpress.org/changeset/60939|60939]]

 Follow-up to [52039], [55988], [56245], [60269], [60939]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65408>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list