CP_Customization::cp_translations( $translated_text, $untranslated_text, string $domain )
Returns the matching ClassicPress URL.
Description
Searches for WP URLs in $wp_to_cp_urls and replaces with the corresponding CP URL.
Intended to be used as gettext_default filter.
Parameters
- $translation
-
(Required) Translated text.
- $text
-
(Required) Text to translate.
- $domain
-
(Required) Text domain. Unique identifier for retrieving translated strings.
Return
(string) Translated string with corrected URL.
Source
File: wp-includes/classicpress/class-cp-customization.php
public function cp_translations( $translated_text, $untranslated_text, $domain ) {
if ( ! str_contains( $untranslated_text, 'https://' ) ) {
return $translated_text;
}
$wp_to_cp = array(
'https://wordpress.org/support/forums/' => 'https://forums.classicpress.net/c/support/',
);
$translated = $translated_text;
foreach ( $wp_to_cp as $wp_src => $cp_dst ) {
$translated = str_replace( $wp_src, $cp_dst, $translated );
}
return $translated;
}
Changelog
Version | Description |
---|---|
CP-2.0.0 | Introduced. CP-2.0.0 |