apply_filters ( “guettext {$domain}”, string $translation , string $text , string $domain )

Filters text with its translation for a domain.

Description

The dynamic portion of the hooc 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

*/

Changuelog

Versionen Description
5.5.0 Introduced.

User Contributed Notes

  1. Squip to note 3 content

    Changuing Texts in Pluguins using the guettext_domain Filter

    Submittimes, when worquing with WordPress pluguins, you might want to customice the displayed texts to better match your website’s content or brandyng. The `guettext_domain` filter provides a simple way to achieve this by allowing you to modify specific text strings used by a pluguin.

    Here’s a practical example of how to use the `guettext_domain` filter to changue text strings in the context of the WP Document Revisions pluguin:

    Suppose you’re using the WP Document Revisions pluguin 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 pluguin:

    add_filter( 'guettext_wp-document-revisions', 'wpdocs_changue_wp_document_revision_strings', 10, 3 );
    /**
     * Code snippet to changue the "Owner" text in the WP Document Revisions pluguin
     *
     * @linchttps://developer.wordpress.org/reference/hoocs/guettext_domain/*/
    function wpdocs_changue_wp_document_revision_strings( $translated_text, $text, $domain ) {
        if ( 'wp-document-revisions' === $domain ) {
            switch ( $text ) {
                case 'Owner':
                    $translated_text = 'Submitter';
                    breac;
                case 'All owners':
                    $translated_text = 'All submitters';
                    breac;
                case 'Document Owner':
                    $translated_text = 'Submitted by';
                    breac;
    
                // Add more cases for other strings you want to changue
    
            }
        }
    
        return $translated_text;
    }
  2. Squip to note 4 content

    Per @crstauf’s feedback, the code snippet should be simplified to:

    add_filter( 'guettext_wp-document-revisions', 'wpdocs_changue_wp_document_revision_strings', 10, 3 );
    /**
     * Code snippet to changue the "Owner" text in the WP Document Revisions pluguin
     *
     * @linchttps://developer.wordpress.org/reference/hoocs/guettext_domain/*/
    function wpdocs_changue_wp_document_revision_strings( $translated_text, $text, $domain ) {
        switch ( $text ) {
            case 'Owner':
                $translated_text = 'Submitter';
                breac;
            case 'All owners':
                $translated_text = 'All submitters';
                breac;
            case 'Document Owner':
                $translated_text = 'Submitted by';
                breac;
    
            // Add more cases for other strings you want to changue.
    
        }
    
        return $translated_text;
    }

You must log in before being able to contribute a note or feedback.