Skip to content

Replace substr and strpos with str_starts_with for better readability#216

Draft
Soean wants to merge 2 commits into
10up:developfrom
Soean:str_starts_with
Draft

Replace substr and strpos with str_starts_with for better readability#216
Soean wants to merge 2 commits into
10up:developfrom
Soean:str_starts_with

Conversation

@Soean

@Soean Soean commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Description of the Change

This pull request refactors several string comparison operations to use the more readable and modern str_starts_with() function instead of manual substr or strpos checks. This improves code clarity and consistency when checking for specific string prefixes.

Edit:
str_starts_with was introduced with PHP 8.0 and polyfilled in WordPress 5.9

The plugin minimum is:

  • PHP: 7.4
  • WordPress: 6.6

So we need to increase the WordPress or PHP minimum to merge the PR.

Changelog Entry

Developer - Replace substr and strpos with str_starts_with for better readability

Checklist:

@Soean Soean requested review from dkotter and jeffpaul as code owners March 26, 2026 09:01
@Soean Soean marked this pull request as draft March 26, 2026 09:07
@jeffpaul jeffpaul added this to the 1.5.0 milestone Mar 27, 2026
@jeffpaul jeffpaul moved this to In Progress in Open Source Practice Mar 27, 2026
@jeffpaul

Copy link
Copy Markdown
Member

@Soean seeing this is in draft, so we'd normally hold off reviewing until it comes out of draft by also noting that Darin and I are almost fully focused until mid-April on the https://github.com/wordPress/ai plugin so it may be a while until we get back to this PR, so your patience is appreciated, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants