Skip to content

fix: read setting defaults without building the translated settings fields - #582

Merged
ramiy merged 3 commits into
core-betafrom
fix/early-settings-textdomain/core
Oct 12, 2026
Merged

ramiy merged 3 commits into
core-betafrom
fix/early-settings-textdomain/core

Conversation

@TallblokeUK

Copy link
Copy Markdown
Contributor

Re-applies 004a4f6, which #564 undid along with the other commits from 21 September. Settings_Fields.php on core-beta and at v4.0.0-beta.3 is identical to how it stood before that fix.

Reading any setting built every settings field, translated labels included. The shortcode handler reads a setting on the_posts, which fires for any post query, so a query made while plugins are still loading requested translations before WordPress allows them. WordPress reports that as _load_textdomain_just_in_time was called incorrectly, and with debug display on the notice is printed ahead of the headers.

Reported against 3.10.0 and 3.10.2: https://wordpress.org/support/topic/translation-loading-too-early-in-code-snippets-3-10-2/

Verification

  • Reproduced on the released 3.10.2 and on core-beta with a non-English locale and a post query on plugins_loaded; the notice traces to Settings_Fields::init_fields() via Shortcodes::enqueue_highlighting(). With this change the same request raises nothing, and the settings screen still renders.
  • New tests read a setting, and run a post query, and assert nothing is translated in the plugin's text domain. Each runs in its own process, because the field definitions are built once per process. Both fail without the change, alone and within the full suite.
  • Full PHPUnit suite (355 tests) and lint:php pass.

@TallblokeUK TallblokeUK added the run-tests Trigger automated tests label Oct 11, 2026
@ramiy
ramiy merged commit 0e5eb53 into core-beta Oct 12, 2026
43 of 46 checks passed
@ramiy
ramiy deleted the fix/early-settings-textdomain/core branch October 12, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-tests Trigger automated tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants