Skip to content

Plugins: Match translated plugin data in the Installed Plugins search#12336

Open
dhrupo wants to merge 3 commits into
WordPress:trunkfrom
dhrupo:ticket-64188-search-translated-plugin-names
Open

Plugins: Match translated plugin data in the Installed Plugins search#12336
dhrupo wants to merge 3 commits into
WordPress:trunkfrom
dhrupo:ticket-64188-search-translated-plugin-names

Conversation

@dhrupo

@dhrupo dhrupo commented Jun 27, 2026

Copy link
Copy Markdown

Summary

Make the Installed Plugins search (Plugins → Installed Plugins) match the translated plugin name, description, and author that are shown in the list — not only the original (untranslated) values from the plugin file headers.

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

Problem

When WordPress runs in a non-English locale, the Installed Plugins list table displays translated plugin names (from the plugin's .mo files). However, the search box only matched against the raw, untranslated plugin headers. Searching for a plugin by the name shown in the list returned no results.

This is also inconsistent with the Add Plugins screen, whose search already matches translated names.

In WP_Plugins_List_Table::prepare_items() the search runs against the raw get_plugins() data:

$plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) );

…while the data is only passed through _get_plugin_data_markup_translate() for display afterwards:

$this->items[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );

So the user sees translated names but searches against untranslated strings.

Solution

  • Pass the plugin file path into _search_callback() using ARRAY_FILTER_USE_BOTH.
  • In _search_callback(), in addition to the original header values, also match against the translated plugin data returned by _get_plugin_data_markup_translate().
  • The original (untranslated) values are still searched, so finding a plugin by its English/original name continues to work. The second parameter is optional, preserving backward compatibility for any external callers.

The extra translation work only runs while a search is active.

Testing instructions

Reproduction via WordPress Playground (provided on the ticket):
https://playground.wordpress.net/?language=de_DE&url=%2Fwp-admin%2Fplugins.php%3Fs%3Dnicht

Manual:

  1. Install a plugin that ships translations for its name (e.g. Event Organiser).
  2. Set Site Language to a locale with that translation (e.g. Polish) in Settings → General.
  3. Go to Plugins → Installed Plugins. The plugin shows its translated name.
  4. Search for the translated name.
    • Before: 0 results.
    • After: the plugin is found. Searching by the original name still works too.

Automated:

phpunit tests/phpunit/tests/admin/wpPluginsListTable.php

New regression tests cover search by translated name, search by original (untranslated) name, and a non-matching term. The translated-name test fails on trunk and passes with this change.

Use of AI Tools

  • AI assistance: Yes
  • Tool(s): Claude Code
  • Model(s): Claude Opus 4.8
  • Used for: Root-cause analysis, drafting the fix and the PHPUnit regression tests. All changes were reviewed, reproduced live in the wordpress-develop Docker environment (before/after), and verified against PHPUnit and PHPCS by me.

The Installed Plugins list table displays translated plugin names,
descriptions, and authors, but the search filtered against the raw
(untranslated) plugin headers only. As a result, searching by the
displayed (translated) name returned no results, even though the
Add Plugins screen already matches translated names.

Pass the plugin file to WP_Plugins_List_Table::_search_callback() via
ARRAY_FILTER_USE_BOTH and also match against the translated plugin data
from _get_plugin_data_markup_translate(), while still matching the
original headers so searches by the untranslated value keep working.

Adds regression tests covering search by translated name, original
name, and a non-matching term.

Fixes #64188.
@github-actions

Copy link
Copy Markdown

Hi there! 👋

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 27, 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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dhrupo, apermo.

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

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.


foreach ( $plugin_data_sets as $plugin_data ) {
foreach ( $plugin_data as $value ) {
if ( is_string( $value ) && false !== stripos( strip_tags( $value ), $term ) ) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this can be simplified by using str-contains()

WordPress comes with a polyfil since 5.9

@dhrupo dhrupo Jun 28, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, you're right — the false !== stripos() is clunky. I've gone ahead and switched it to str_contains() (lowercasing both sides so the search stays case-insensitive). 👍

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — switched it to str_contains() in a26c5cc. I lowercased both sides first so the search stays case-insensitive (otherwise typing akismet would stop matching Akismet), and added a couple of mixed-case test cases to lock that in. Reads much nicer than the false !== stripos() dance, thanks for the nudge 👍

@apermo

apermo commented Jun 27, 2026

Copy link
Copy Markdown

And mind that you want a ticket on trac related to this PR, otherwise it won't be prioritized

@dhrupo

dhrupo commented Jun 28, 2026

Copy link
Copy Markdown
Author

Thanks for the heads-up! There is a ticket already, #64188, linked at the top of the description. It's showing the PR and has-patch on the Trac side now too, so it should be on the radar. Appreciate you checking 🙌

dhrupo added 2 commits June 28, 2026 16:19
Replace the false !== stripos() idiom with str_contains() per review
feedback. The search term and each value are lowercased first so the
search stays case-insensitive, and tests are added to cover matching
across different letter cases.
Fixes a WordPress.Arrays.MultipleStatementAlignment warning flagged by
the test suite coding-standards scan.
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.

2 participants