WP_Translation_Controller::has_translation()
Returns a boolean to indicate whether a translation exists for a given string with optional text domain and locale.
Method of the class: WP_Translation_Controller{}
No Hooks.
Return
true|false
. True if the translation exists, false otherwise.
Usage
$WP_Translation_Controller = new WP_Translation_Controller(); $WP_Translation_Controller->has_translation( $singular, $textdomain, ?string $locale ): bool;
- $singular(string) (required)
- Singular translation to check.
- $textdomain(string)
- Text domain.
Default: 'default' - ?string $locale **
- -
Default: null
Changelog
Since 6.7.0 | Introduced. |
WP_Translation_Controller::has_translation() WP Translation Controller::has translation code WP 6.7.1
public function has_translation( string $singular, string $textdomain = 'default', ?string $locale = null ): bool { if ( null === $locale ) { $locale = $this->current_locale; } return false !== $this->locate_translation( $singular, $textdomain, $locale ); }