Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Soft-deprecate load_*_textdomain() functions #7480

Closed

Conversation

swissspidy
Copy link
Member

(Soft) deprecate load_plugin_textdomain() and load_theme_textdomain() and rely solely on the just-in-time loading and WP_Textdomain_Registry.

This would avoid any _doing_it_wrong messages for plugins still using load_plugin_textdomain(), which seems to be the most common case and affects even very big plugins. So it would drastically reduce the noise.

It would still trigger a _doing_it_wrong message if accidentally causing the just-in-time loading too early.

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


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.

Copy link

github-actions bot commented Oct 2, 2024

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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • 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.

@swissspidy
Copy link
Member Author

Only 1 failing test, that sounds doable :-)

1) WP_Test_REST_Themes_Controller::test_theme_tags
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 (
-    0 => 'holiday'
+    0 => 'Holiday'
     1 => 'custom-menu'
 )

/var/www/tests/phpunit/tests/rest-api/rest-themes-controller.php:585

@swissspidy
Copy link
Member Author

OK when I remove the now unused plugin_locale and theme_locale filters a couple of more tests are failing, because they hook into those filters. But nothing is actually broken.

@swissspidy swissspidy marked this pull request as ready for review October 2, 2024 11:15
Copy link

github-actions bot commented Oct 2, 2024

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 swissspidy, sergeybiryukov, mukesh27.

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

* @param string $locale The plugin's current locale.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*/
$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
Copy link
Member

Choose a reason for hiding this comment

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

Q: Many plugins uses the filter https://wpdirectory.net/search/01J96KCH95TBF66SB7N0PKAFM2. We are going to remove these?

Copy link
Member Author

Choose a reason for hiding this comment

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

With the removal of this code there is nothing this filter could be used for anymore. If a plugin is hooking into that filter it simply won't do anything.

We could consider using apply_filters_deprecated without actually using the filter. There's prior art here:

/**
* Filters whether the REST API is enabled.
*
* @since 4.4.0
* @deprecated 4.7.0 Use the {@see 'rest_authentication_errors'} filter to
* restrict access to the REST API.
*
* @param bool $rest_enabled Whether the REST API is enabled. Default true.
*/
apply_filters_deprecated(
'rest_enabled',
array( true ),
'4.7.0',
'rest_authentication_errors',
sprintf(
/* translators: %s: rest_authentication_errors */
__( 'The REST API can no longer be completely disabled, the %s filter can be used to restrict access to the API, instead.' ),
'rest_authentication_errors'
)
);

Copy link
Member Author

Choose a reason for hiding this comment

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

On second thought, I don't think apply_filters_deprecated makes sense though. If you're developing a custom plugin there's a legitimate use for using load_plugin_textdomain(). You shouldn't be faced with a deprecation warning even if you use it properly.

@swissspidy
Copy link
Member Author

@swissspidy swissspidy closed this Oct 2, 2024
@swissspidy swissspidy deleted the fix/44937-soft-deprecate branch October 2, 2024 13:42
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.

3 participants