Make WordPress Core

Changeset 62964


Ignore:
Timestamp:
08/01/2026 04:42:13 PM (6 weeks ago)
Author:
SergeyBiryukov
Message:

HTML API: Use str_contains() instead of strpos() in WP_HTML_Tag_Processor.

The str_contains() function was introduced in PHP 8.0 and a polyfill is available in WordPress Core, making the intent of the check clearer than comparing the result of strpos() against false.

Follow-up to [62687].

Props Soean, mukesh27, westonruter.
See #64897.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php

    r62960 r62964  
    20742074                                $is_valid_pi = (
    20752075                                        0 !== $target_length &&
    2076                                         false !== strpos( " \t\f\r\n?>", $html[ $target_at + $target_length ] ) &&
     2076                                        str_contains( " \t\f\r\n?>", $html[ $target_at + $target_length ] ) &&
    20772077                                        ! ( 3 === $target_length && 0 === substr_compare( $html, 'xml', $target_at, 3, true ) ) &&
    20782078                                        ! ( 14 === $target_length && 0 === substr_compare( $html, 'xml-stylesheet', $target_at, 14, true ) )
Note: See TracChangeset for help on using the changeset viewer.