Skip to content

Code Modernization: Use str_contains() in wp-includes/blocks/cover.php#12123

Open
Dervish12 wants to merge 1 commit into
WordPress:trunkfrom
Dervish12:trac/65408-str-contains-continued
Open

Code Modernization: Use str_contains() in wp-includes/blocks/cover.php#12123
Dervish12 wants to merge 1 commit into
WordPress:trunkfrom
Dervish12:trac/65408-str-contains-continued

Conversation

@Dervish12

Copy link
Copy Markdown

Summary

Replace strpos() !== false with str_contains() in the Cover block's video provider detection logic (src/wp-includes/blocks/cover.php).

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

This PR replaces strpos( $lower_src, '...' ) !== false patterns with str_contains() in the Cover block, making the code more readable and consistent, as well as better aligned with modern PHP development practices.

Follow-up to r60269 and r60939.

Trac ticket: https://core.trac.wordpress.org/ticket/65408

Changes

  • Replaced 4 instances of strpos( $lower_src, '...' ) !== false with str_contains( $lower_src, '...' ) in the video provider detection within render_block_core_cover().

Test plan

  • npm run test:php -- --filter='cover' — all 47 tests pass
  • ./vendor/bin/phpcs --standard=phpcs.xml.dist src/wp-includes/blocks/cover.php — no PHPCS violations
  • Verify Cover block with embedded YouTube, Vimeo, VideoPress, and WordPress.tv videos renders correctly

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Replace `strpos() !== false` with `str_contains()` in the Cover block's
video provider detection logic.

`str_contains()` was introduced in PHP 8.0 and WordPress includes a
polyfill since version 5.9. This makes the code more readable and
aligns with the ongoing modernization effort.

Follow-up to [r60269], [r60939].

Trac ticket: https://core.trac.wordpress.org/ticket/65408

Props Dervish12.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Hi @Dervish12! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @Dervish12.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant