WordPress / WordPress/plugin-check

Single file plugin text domain check yields mixed and incorrect expected strings

Open
#745 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Type] Bug
Dominant language
PHP
Stars
362
Forks
126
Avg merge
1d 23h
Merged PRs (30d)
22

Description

For a single file plugin with a text domain set, the WordPress.WP.I18n.TextDomainMismatch check relies on a plugin directory slug (non-existent in this context) and shows different results between the UI and CLI. It has been suggested that this check be bypassed for single-file plugins (hat tip @ernilambar).

To test this, I added the hello-dolly text domain to the hello.php plugin that ships with WP core (required to avoid an error with the WordPress.WP.I18n.MissingArgDomain check):

__( 'Quote from Hello Dolly song, by Jerry Herman:', 'hello-dolly' ),

Running PCP, the admin shows
Mismatched text domain. Expected 'plugins' but got 'hello-dolly'.
whereas the CLI returns
Mismatched text domain. Expected 'hello.php' but got 'hello-dolly'.

Originally reported at https://github.com/WordPress/plugin-check/issues/713#issuecomment-2408257109.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WordPress.WP.I18n.TextDomainMismatch check and compare how the admin and CLI determine the expected text domain. Reproduce the discrepancy using the hello.php example with the hello-dolly domain. Done means single-file plugins are handled consistently and the admin and CLI no longer report different expected strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
internationalization, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.