Skip to content

fix: remove load_plugin_textdomain (auto-loaded since WP 4.6) - #120

Merged
jackgranatowski merged 1 commit into
mainfrom
claude/wordpress-translation-loading-5ip7nn
Jun 30, 2026
Merged

fix: remove load_plugin_textdomain (auto-loaded since WP 4.6)#120
jackgranatowski merged 1 commit into
mainfrom
claude/wordpress-translation-loading-5ip7nn

Conversation

@jackgranatowski

@jackgranatowski jackgranatowski commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Removes the load_plugin_textdomain() call from slashed.php entirely. Since WordPress 4.6, translations are loaded automatically for plugins hosted on WordPress.org using the Text Domain plugin header — the explicit call is redundant.
  • This also eliminates the WordPress Plugin Check warning (PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound) flagged on the previous release.

Context

The previous PR (#119) moved the call from plugins_loaded to init to resolve a WP 6.7 _load_textdomain_just_in_time notice. The Plugin Check tool then flagged the call as discouraged since WP 4.6. Removing it entirely is the correct long-term fix — no translation loading code is needed at all.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility with recent WordPress versions by adjusting how plugin localization is initialized.
    • Removed outdated implementation notes and simplified the startup flow.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 180acc10-3f5c-46cd-8a33-97e1c181a147

📥 Commits

Reviewing files that changed from the base of the PR and between 72b15d1 and c2d2bef.

📒 Files selected for processing (1)
  • SLASHED-for-WP/slashed.php
💤 Files with no reviewable changes (1)
  • SLASHED-for-WP/slashed.php

📝 Walkthrough

Walkthrough

Removes the add_action( 'init', ... ) hook that called load_plugin_textdomain( 'slashed', ... ) from slashed.php, along with its associated comment block. The file now proceeds directly to the canonical constants section after the ABSPATH guard.

Changes

Remove textdomain init hook

Layer / File(s) Summary
Remove load_plugin_textdomain init action
SLASHED-for-WP/slashed.php
Removes the add_action( 'init', ... ) wrapper and load_plugin_textdomain( 'slashed', ... ) call, along with surrounding comments.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • codeslash-dev/SLASHED-Plugins#48: Also removes the init hook calling load_plugin_textdomain( 'slashed', ... ) in slashed.php, overlapping directly with this change.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: removing the load_plugin_textdomain call from the plugin.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/wordpress-translation-loading-5ip7nn

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Remove redundant load_plugin_textdomain (WordPress auto-loads since 4.6)

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Remove explicit textdomain loading to rely on WordPress core auto-loading.
• Eliminate Plugin Check warning for discouraged load_plugin_textdomain usage.
Diagram

graph TD
  A["slashed.php"] -->|"no manual load"| B["WP core i18n"] --> C[("languages/")]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep load_plugin_textdomain() on init with a PHPCS ignore
  • ➕ Ensures translations load even when the plugin is distributed outside WordPress.org conventions
  • ➕ Keeps behavior explicit and self-contained
  • ➖ Continues to trigger Plugin Check discouraged-function warnings
  • ➖ Maintains redundant code for the primary wp.org-hosted case
2. Conditional manual load only when not wp.org-managed
  • ➕ Avoids unnecessary manual loading for standard installs
  • ➕ Provides a fallback for custom distribution scenarios
  • ➖ Hard to reliably detect packaging/installation context
  • ➖ Adds branching complexity for minimal practical benefit

Recommendation: Proceed with removing load_plugin_textdomain() entirely, as it aligns with WordPress 4.6+ auto-loading behavior and resolves the Plugin Check warning. Only reconsider if this plugin is commonly installed via non-wp.org packaging where auto-loading is not guaranteed.

Files changed (1) +0 / -14

Bug fix (1) +0 / -14
slashed.phpRemove init hook that manually loads the plugin textdomain +0/-14

Remove init hook that manually loads the plugin textdomain

• Deletes the init-priority hook and accompanying rationale comments that called load_plugin_textdomain(). Translation loading is now left to WordPress core auto-loading behavior, avoiding the Plugin Check discouraged-function warning.

SLASHED-for-WP/slashed.php

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

@jackgranatowski
jackgranatowski merged commit 077c304 into main Jun 30, 2026
9 checks passed
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