apply_filters( "gettext_{$domain}", string $translation , string $text , string $domain )
Filters text with its translation for a domain.
Description
The dynamic portion of the hook name, $domain
, refers to the text domain.
Parameters
-
$translation
string -
Translated text.
-
$text
string -
Text to translate.
-
$domain
string -
Text domain. Unique identifier for retrieving translated strings.
Source
File: wp-includes/l10n.php
.
View all references
$translation = apply_filters( "gettext_{$domain}", $translation, $text, $domain );
Changelog
Version | Description |
---|---|
5.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Changing Texts in Plugins using the gettext_domain Filter
Sometimes, when working with WordPress plugins, you might want to customize the displayed texts to better match your website’s content or branding. The `gettext_domain` filter provides a simple way to achieve this by allowing you to modify specific text strings used by a plugin.
Here’s a practical example of how to use the `gettext_domain` filter to change text strings in the context of the WP Document Revisions plugin:
Suppose you’re using the WP Document Revisions plugin and want to replace the term “Owner” with “Submitter” in various instances throughout your site.
You can achieve this by adding the following code snippet to your theme’s `functions.php` file or a custom plugin:
Top ↑
Feedback
The dynamic portion of the hook ensures that the filter only applies to the specified domain, so the
'wp-document-revisions' === $domain
check is redundant. — By crstauf —