Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: l10n.php
[1000] Fix | Delete
/**
[1001] Fix | Delete
* Filters a plugin's locale.
[1002] Fix | Delete
*
[1003] Fix | Delete
* @since 3.0.0
[1004] Fix | Delete
*
[1005] Fix | Delete
* @param string $locale The plugin's current locale.
[1006] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[1007] Fix | Delete
*/
[1008] Fix | Delete
$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
[1009] Fix | Delete
[1010] Fix | Delete
$mofile = $domain . '-' . $locale . '.mo';
[1011] Fix | Delete
[1012] Fix | Delete
// Try to load from the languages directory first.
[1013] Fix | Delete
if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile, $locale ) ) {
[1014] Fix | Delete
return true;
[1015] Fix | Delete
}
[1016] Fix | Delete
[1017] Fix | Delete
if ( false !== $plugin_rel_path ) {
[1018] Fix | Delete
$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
[1019] Fix | Delete
} elseif ( false !== $deprecated ) {
[1020] Fix | Delete
_deprecated_argument( __FUNCTION__, '2.7.0' );
[1021] Fix | Delete
$path = ABSPATH . trim( $deprecated, '/' );
[1022] Fix | Delete
} else {
[1023] Fix | Delete
$path = WP_PLUGIN_DIR;
[1024] Fix | Delete
}
[1025] Fix | Delete
[1026] Fix | Delete
$wp_textdomain_registry->set_custom_path( $domain, $path );
[1027] Fix | Delete
[1028] Fix | Delete
return load_textdomain( $domain, $path . '/' . $mofile, $locale );
[1029] Fix | Delete
}
[1030] Fix | Delete
[1031] Fix | Delete
/**
[1032] Fix | Delete
* Loads the translated strings for a plugin residing in the mu-plugins directory.
[1033] Fix | Delete
*
[1034] Fix | Delete
* @since 3.0.0
[1035] Fix | Delete
* @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
[1036] Fix | Delete
*
[1037] Fix | Delete
* @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
[1038] Fix | Delete
*
[1039] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[1040] Fix | Delete
* @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
[1041] Fix | Delete
* file resides. Default empty string.
[1042] Fix | Delete
* @return bool True when textdomain is successfully loaded, false otherwise.
[1043] Fix | Delete
*/
[1044] Fix | Delete
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
[1045] Fix | Delete
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
[1046] Fix | Delete
global $wp_textdomain_registry;
[1047] Fix | Delete
[1048] Fix | Delete
if ( ! is_string( $domain ) ) {
[1049] Fix | Delete
return false;
[1050] Fix | Delete
}
[1051] Fix | Delete
[1052] Fix | Delete
/** This filter is documented in wp-includes/l10n.php */
[1053] Fix | Delete
$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
[1054] Fix | Delete
[1055] Fix | Delete
$mofile = $domain . '-' . $locale . '.mo';
[1056] Fix | Delete
[1057] Fix | Delete
// Try to load from the languages directory first.
[1058] Fix | Delete
if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile, $locale ) ) {
[1059] Fix | Delete
return true;
[1060] Fix | Delete
}
[1061] Fix | Delete
[1062] Fix | Delete
$path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );
[1063] Fix | Delete
[1064] Fix | Delete
$wp_textdomain_registry->set_custom_path( $domain, $path );
[1065] Fix | Delete
[1066] Fix | Delete
return load_textdomain( $domain, $path . '/' . $mofile, $locale );
[1067] Fix | Delete
}
[1068] Fix | Delete
[1069] Fix | Delete
/**
[1070] Fix | Delete
* Loads the theme's translated strings.
[1071] Fix | Delete
*
[1072] Fix | Delete
* If the current locale exists as a .mo file in the theme's root directory, it
[1073] Fix | Delete
* will be included in the translated strings by the $domain.
[1074] Fix | Delete
*
[1075] Fix | Delete
* The .mo files must be named based on the locale exactly.
[1076] Fix | Delete
*
[1077] Fix | Delete
* @since 1.5.0
[1078] Fix | Delete
* @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
[1079] Fix | Delete
*
[1080] Fix | Delete
* @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
[1081] Fix | Delete
*
[1082] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[1083] Fix | Delete
* @param string|false $path Optional. Path to the directory containing the .mo file.
[1084] Fix | Delete
* Default false.
[1085] Fix | Delete
* @return bool True when textdomain is successfully loaded, false otherwise.
[1086] Fix | Delete
*/
[1087] Fix | Delete
function load_theme_textdomain( $domain, $path = false ) {
[1088] Fix | Delete
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
[1089] Fix | Delete
global $wp_textdomain_registry;
[1090] Fix | Delete
[1091] Fix | Delete
if ( ! is_string( $domain ) ) {
[1092] Fix | Delete
return false;
[1093] Fix | Delete
}
[1094] Fix | Delete
[1095] Fix | Delete
/**
[1096] Fix | Delete
* Filters a theme's locale.
[1097] Fix | Delete
*
[1098] Fix | Delete
* @since 3.0.0
[1099] Fix | Delete
*
[1100] Fix | Delete
* @param string $locale The theme's current locale.
[1101] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[1102] Fix | Delete
*/
[1103] Fix | Delete
$locale = apply_filters( 'theme_locale', determine_locale(), $domain );
[1104] Fix | Delete
[1105] Fix | Delete
$mofile = $domain . '-' . $locale . '.mo';
[1106] Fix | Delete
[1107] Fix | Delete
// Try to load from the languages directory first.
[1108] Fix | Delete
if ( load_textdomain( $domain, WP_LANG_DIR . '/themes/' . $mofile, $locale ) ) {
[1109] Fix | Delete
return true;
[1110] Fix | Delete
}
[1111] Fix | Delete
[1112] Fix | Delete
if ( ! $path ) {
[1113] Fix | Delete
$path = get_template_directory();
[1114] Fix | Delete
}
[1115] Fix | Delete
[1116] Fix | Delete
$wp_textdomain_registry->set_custom_path( $domain, $path );
[1117] Fix | Delete
[1118] Fix | Delete
return load_textdomain( $domain, $path . '/' . $locale . '.mo', $locale );
[1119] Fix | Delete
}
[1120] Fix | Delete
[1121] Fix | Delete
/**
[1122] Fix | Delete
* Loads the child theme's translated strings.
[1123] Fix | Delete
*
[1124] Fix | Delete
* If the current locale exists as a .mo file in the child theme's
[1125] Fix | Delete
* root directory, it will be included in the translated strings by the $domain.
[1126] Fix | Delete
*
[1127] Fix | Delete
* The .mo files must be named based on the locale exactly.
[1128] Fix | Delete
*
[1129] Fix | Delete
* @since 2.9.0
[1130] Fix | Delete
*
[1131] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[1132] Fix | Delete
* @param string|false $path Optional. Path to the directory containing the .mo file.
[1133] Fix | Delete
* Default false.
[1134] Fix | Delete
* @return bool True when the theme textdomain is successfully loaded, false otherwise.
[1135] Fix | Delete
*/
[1136] Fix | Delete
function load_child_theme_textdomain( $domain, $path = false ) {
[1137] Fix | Delete
if ( ! $path ) {
[1138] Fix | Delete
$path = get_stylesheet_directory();
[1139] Fix | Delete
}
[1140] Fix | Delete
return load_theme_textdomain( $domain, $path );
[1141] Fix | Delete
}
[1142] Fix | Delete
[1143] Fix | Delete
/**
[1144] Fix | Delete
* Loads the script translated strings.
[1145] Fix | Delete
*
[1146] Fix | Delete
* @since 5.0.0
[1147] Fix | Delete
* @since 5.0.2 Uses load_script_translations() to load translation data.
[1148] Fix | Delete
* @since 5.1.0 The `$domain` parameter was made optional.
[1149] Fix | Delete
*
[1150] Fix | Delete
* @see WP_Scripts::set_translations()
[1151] Fix | Delete
*
[1152] Fix | Delete
* @param string $handle Name of the script to register a translation domain to.
[1153] Fix | Delete
* @param string $domain Optional. Text domain. Default 'default'.
[1154] Fix | Delete
* @param string $path Optional. The full file path to the directory containing translation files.
[1155] Fix | Delete
* @return string|false The translated strings in JSON encoding on success,
[1156] Fix | Delete
* false if the script textdomain could not be loaded.
[1157] Fix | Delete
*/
[1158] Fix | Delete
function load_script_textdomain( $handle, $domain = 'default', $path = '' ) {
[1159] Fix | Delete
$wp_scripts = wp_scripts();
[1160] Fix | Delete
[1161] Fix | Delete
if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
[1162] Fix | Delete
return false;
[1163] Fix | Delete
}
[1164] Fix | Delete
[1165] Fix | Delete
$path = untrailingslashit( $path );
[1166] Fix | Delete
$locale = determine_locale();
[1167] Fix | Delete
[1168] Fix | Delete
// If a path was given and the handle file exists simply return it.
[1169] Fix | Delete
$file_base = 'default' === $domain ? $locale : $domain . '-' . $locale;
[1170] Fix | Delete
$handle_filename = $file_base . '-' . $handle . '.json';
[1171] Fix | Delete
[1172] Fix | Delete
if ( $path ) {
[1173] Fix | Delete
$translations = load_script_translations( $path . '/' . $handle_filename, $handle, $domain );
[1174] Fix | Delete
[1175] Fix | Delete
if ( $translations ) {
[1176] Fix | Delete
return $translations;
[1177] Fix | Delete
}
[1178] Fix | Delete
}
[1179] Fix | Delete
[1180] Fix | Delete
$src = $wp_scripts->registered[ $handle ]->src;
[1181] Fix | Delete
[1182] Fix | Delete
if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $wp_scripts->content_url && str_starts_with( $src, $wp_scripts->content_url ) ) ) {
[1183] Fix | Delete
$src = $wp_scripts->base_url . $src;
[1184] Fix | Delete
}
[1185] Fix | Delete
[1186] Fix | Delete
$relative = false;
[1187] Fix | Delete
$languages_path = WP_LANG_DIR;
[1188] Fix | Delete
[1189] Fix | Delete
$src_url = wp_parse_url( $src );
[1190] Fix | Delete
$content_url = wp_parse_url( content_url() );
[1191] Fix | Delete
$plugins_url = wp_parse_url( plugins_url() );
[1192] Fix | Delete
$site_url = wp_parse_url( site_url() );
[1193] Fix | Delete
[1194] Fix | Delete
// If the host is the same or it's a relative URL.
[1195] Fix | Delete
if (
[1196] Fix | Delete
( ! isset( $content_url['path'] ) || str_starts_with( $src_url['path'], $content_url['path'] ) ) &&
[1197] Fix | Delete
( ! isset( $src_url['host'] ) || ! isset( $content_url['host'] ) || $src_url['host'] === $content_url['host'] )
[1198] Fix | Delete
) {
[1199] Fix | Delete
// Make the src relative the specific plugin or theme.
[1200] Fix | Delete
if ( isset( $content_url['path'] ) ) {
[1201] Fix | Delete
$relative = substr( $src_url['path'], strlen( $content_url['path'] ) );
[1202] Fix | Delete
} else {
[1203] Fix | Delete
$relative = $src_url['path'];
[1204] Fix | Delete
}
[1205] Fix | Delete
$relative = trim( $relative, '/' );
[1206] Fix | Delete
$relative = explode( '/', $relative );
[1207] Fix | Delete
[1208] Fix | Delete
$languages_path = WP_LANG_DIR . '/plugins';
[1209] Fix | Delete
[1210] Fix | Delete
$relative = array_slice( $relative, 2 ); // Remove plugins/<plugin name> or themes/<theme name>.
[1211] Fix | Delete
$relative = implode( '/', $relative );
[1212] Fix | Delete
} elseif (
[1213] Fix | Delete
( ! isset( $plugins_url['path'] ) || str_starts_with( $src_url['path'], $plugins_url['path'] ) ) &&
[1214] Fix | Delete
( ! isset( $src_url['host'] ) || ! isset( $plugins_url['host'] ) || $src_url['host'] === $plugins_url['host'] )
[1215] Fix | Delete
) {
[1216] Fix | Delete
// Make the src relative the specific plugin.
[1217] Fix | Delete
if ( isset( $plugins_url['path'] ) ) {
[1218] Fix | Delete
$relative = substr( $src_url['path'], strlen( $plugins_url['path'] ) );
[1219] Fix | Delete
} else {
[1220] Fix | Delete
$relative = $src_url['path'];
[1221] Fix | Delete
}
[1222] Fix | Delete
$relative = trim( $relative, '/' );
[1223] Fix | Delete
$relative = explode( '/', $relative );
[1224] Fix | Delete
[1225] Fix | Delete
$languages_path = WP_LANG_DIR . '/plugins';
[1226] Fix | Delete
[1227] Fix | Delete
$relative = array_slice( $relative, 1 ); // Remove <plugin name>.
[1228] Fix | Delete
$relative = implode( '/', $relative );
[1229] Fix | Delete
} elseif ( ! isset( $src_url['host'] ) || ! isset( $site_url['host'] ) || $src_url['host'] === $site_url['host'] ) {
[1230] Fix | Delete
if ( ! isset( $site_url['path'] ) ) {
[1231] Fix | Delete
$relative = trim( $src_url['path'], '/' );
[1232] Fix | Delete
} elseif ( str_starts_with( $src_url['path'], trailingslashit( $site_url['path'] ) ) ) {
[1233] Fix | Delete
// Make the src relative to the WP root.
[1234] Fix | Delete
$relative = substr( $src_url['path'], strlen( $site_url['path'] ) );
[1235] Fix | Delete
$relative = trim( $relative, '/' );
[1236] Fix | Delete
}
[1237] Fix | Delete
}
[1238] Fix | Delete
[1239] Fix | Delete
/**
[1240] Fix | Delete
* Filters the relative path of scripts used for finding translation files.
[1241] Fix | Delete
*
[1242] Fix | Delete
* @since 5.0.2
[1243] Fix | Delete
*
[1244] Fix | Delete
* @param string|false $relative The relative path of the script. False if it could not be determined.
[1245] Fix | Delete
* @param string $src The full source URL of the script.
[1246] Fix | Delete
*/
[1247] Fix | Delete
$relative = apply_filters( 'load_script_textdomain_relative_path', $relative, $src );
[1248] Fix | Delete
[1249] Fix | Delete
// If the source is not from WP.
[1250] Fix | Delete
if ( false === $relative ) {
[1251] Fix | Delete
return load_script_translations( false, $handle, $domain );
[1252] Fix | Delete
}
[1253] Fix | Delete
[1254] Fix | Delete
// Translations are always based on the unminified filename.
[1255] Fix | Delete
if ( str_ends_with( $relative, '.min.js' ) ) {
[1256] Fix | Delete
$relative = substr( $relative, 0, -7 ) . '.js';
[1257] Fix | Delete
}
[1258] Fix | Delete
[1259] Fix | Delete
$md5_filename = $file_base . '-' . md5( $relative ) . '.json';
[1260] Fix | Delete
[1261] Fix | Delete
if ( $path ) {
[1262] Fix | Delete
$translations = load_script_translations( $path . '/' . $md5_filename, $handle, $domain );
[1263] Fix | Delete
[1264] Fix | Delete
if ( $translations ) {
[1265] Fix | Delete
return $translations;
[1266] Fix | Delete
}
[1267] Fix | Delete
}
[1268] Fix | Delete
[1269] Fix | Delete
$translations = load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain );
[1270] Fix | Delete
[1271] Fix | Delete
if ( $translations ) {
[1272] Fix | Delete
return $translations;
[1273] Fix | Delete
}
[1274] Fix | Delete
[1275] Fix | Delete
return load_script_translations( false, $handle, $domain );
[1276] Fix | Delete
}
[1277] Fix | Delete
[1278] Fix | Delete
/**
[1279] Fix | Delete
* Loads the translation data for the given script handle and text domain.
[1280] Fix | Delete
*
[1281] Fix | Delete
* @since 5.0.2
[1282] Fix | Delete
*
[1283] Fix | Delete
* @param string|false $file Path to the translation file to load. False if there isn't one.
[1284] Fix | Delete
* @param string $handle Name of the script to register a translation domain to.
[1285] Fix | Delete
* @param string $domain The text domain.
[1286] Fix | Delete
* @return string|false The JSON-encoded translated strings for the given script handle and text domain.
[1287] Fix | Delete
* False if there are none.
[1288] Fix | Delete
*/
[1289] Fix | Delete
function load_script_translations( $file, $handle, $domain ) {
[1290] Fix | Delete
/**
[1291] Fix | Delete
* Pre-filters script translations for the given file, script handle and text domain.
[1292] Fix | Delete
*
[1293] Fix | Delete
* Returning a non-null value allows to override the default logic, effectively short-circuiting the function.
[1294] Fix | Delete
*
[1295] Fix | Delete
* @since 5.0.2
[1296] Fix | Delete
*
[1297] Fix | Delete
* @param string|false|null $translations JSON-encoded translation data. Default null.
[1298] Fix | Delete
* @param string|false $file Path to the translation file to load. False if there isn't one.
[1299] Fix | Delete
* @param string $handle Name of the script to register a translation domain to.
[1300] Fix | Delete
* @param string $domain The text domain.
[1301] Fix | Delete
*/
[1302] Fix | Delete
$translations = apply_filters( 'pre_load_script_translations', null, $file, $handle, $domain );
[1303] Fix | Delete
[1304] Fix | Delete
if ( null !== $translations ) {
[1305] Fix | Delete
return $translations;
[1306] Fix | Delete
}
[1307] Fix | Delete
[1308] Fix | Delete
/**
[1309] Fix | Delete
* Filters the file path for loading script translations for the given script handle and text domain.
[1310] Fix | Delete
*
[1311] Fix | Delete
* @since 5.0.2
[1312] Fix | Delete
*
[1313] Fix | Delete
* @param string|false $file Path to the translation file to load. False if there isn't one.
[1314] Fix | Delete
* @param string $handle Name of the script to register a translation domain to.
[1315] Fix | Delete
* @param string $domain The text domain.
[1316] Fix | Delete
*/
[1317] Fix | Delete
$file = apply_filters( 'load_script_translation_file', $file, $handle, $domain );
[1318] Fix | Delete
[1319] Fix | Delete
if ( ! $file || ! is_readable( $file ) ) {
[1320] Fix | Delete
return false;
[1321] Fix | Delete
}
[1322] Fix | Delete
[1323] Fix | Delete
$translations = file_get_contents( $file );
[1324] Fix | Delete
[1325] Fix | Delete
/**
[1326] Fix | Delete
* Filters script translations for the given file, script handle and text domain.
[1327] Fix | Delete
*
[1328] Fix | Delete
* @since 5.0.2
[1329] Fix | Delete
*
[1330] Fix | Delete
* @param string $translations JSON-encoded translation data.
[1331] Fix | Delete
* @param string $file Path to the translation file that was loaded.
[1332] Fix | Delete
* @param string $handle Name of the script to register a translation domain to.
[1333] Fix | Delete
* @param string $domain The text domain.
[1334] Fix | Delete
*/
[1335] Fix | Delete
return apply_filters( 'load_script_translations', $translations, $file, $handle, $domain );
[1336] Fix | Delete
}
[1337] Fix | Delete
[1338] Fix | Delete
/**
[1339] Fix | Delete
* Loads plugin and theme text domains just-in-time.
[1340] Fix | Delete
*
[1341] Fix | Delete
* When a textdomain is encountered for the first time, we try to load
[1342] Fix | Delete
* the translation file from `wp-content/languages`, removing the need
[1343] Fix | Delete
* to call load_plugin_textdomain() or load_theme_textdomain().
[1344] Fix | Delete
*
[1345] Fix | Delete
* @since 4.6.0
[1346] Fix | Delete
* @access private
[1347] Fix | Delete
*
[1348] Fix | Delete
* @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
[1349] Fix | Delete
* @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
[1350] Fix | Delete
*
[1351] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[1352] Fix | Delete
* @return bool True when the textdomain is successfully loaded, false otherwise.
[1353] Fix | Delete
*/
[1354] Fix | Delete
function _load_textdomain_just_in_time( $domain ) {
[1355] Fix | Delete
/** @var WP_Textdomain_Registry $wp_textdomain_registry */
[1356] Fix | Delete
global $l10n_unloaded, $wp_textdomain_registry;
[1357] Fix | Delete
[1358] Fix | Delete
$l10n_unloaded = (array) $l10n_unloaded;
[1359] Fix | Delete
[1360] Fix | Delete
// Short-circuit if domain is 'default' which is reserved for core.
[1361] Fix | Delete
if ( 'default' === $domain || isset( $l10n_unloaded[ $domain ] ) ) {
[1362] Fix | Delete
return false;
[1363] Fix | Delete
}
[1364] Fix | Delete
[1365] Fix | Delete
if ( ! $wp_textdomain_registry->has( $domain ) ) {
[1366] Fix | Delete
return false;
[1367] Fix | Delete
}
[1368] Fix | Delete
[1369] Fix | Delete
$locale = determine_locale();
[1370] Fix | Delete
$path = $wp_textdomain_registry->get( $domain, $locale );
[1371] Fix | Delete
if ( ! $path ) {
[1372] Fix | Delete
return false;
[1373] Fix | Delete
}
[1374] Fix | Delete
// Themes with their language directory outside of WP_LANG_DIR have a different file name.
[1375] Fix | Delete
$template_directory = trailingslashit( get_template_directory() );
[1376] Fix | Delete
$stylesheet_directory = trailingslashit( get_stylesheet_directory() );
[1377] Fix | Delete
if ( str_starts_with( $path, $template_directory ) || str_starts_with( $path, $stylesheet_directory ) ) {
[1378] Fix | Delete
$mofile = "{$path}{$locale}.mo";
[1379] Fix | Delete
} else {
[1380] Fix | Delete
$mofile = "{$path}{$domain}-{$locale}.mo";
[1381] Fix | Delete
}
[1382] Fix | Delete
[1383] Fix | Delete
return load_textdomain( $domain, $mofile, $locale );
[1384] Fix | Delete
}
[1385] Fix | Delete
[1386] Fix | Delete
/**
[1387] Fix | Delete
* Returns the Translations instance for a text domain.
[1388] Fix | Delete
*
[1389] Fix | Delete
* If there isn't one, returns empty Translations instance.
[1390] Fix | Delete
*
[1391] Fix | Delete
* @since 2.8.0
[1392] Fix | Delete
*
[1393] Fix | Delete
* @global MO[] $l10n An array of all currently loaded text domains.
[1394] Fix | Delete
*
[1395] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[1396] Fix | Delete
* @return Translations|NOOP_Translations A Translations instance.
[1397] Fix | Delete
*/
[1398] Fix | Delete
function get_translations_for_domain( $domain ) {
[1399] Fix | Delete
global $l10n;
[1400] Fix | Delete
if ( isset( $l10n[ $domain ] ) || ( _load_textdomain_just_in_time( $domain ) && isset( $l10n[ $domain ] ) ) ) {
[1401] Fix | Delete
return $l10n[ $domain ];
[1402] Fix | Delete
}
[1403] Fix | Delete
[1404] Fix | Delete
static $noop_translations = null;
[1405] Fix | Delete
if ( null === $noop_translations ) {
[1406] Fix | Delete
$noop_translations = new NOOP_Translations();
[1407] Fix | Delete
}
[1408] Fix | Delete
[1409] Fix | Delete
$l10n[ $domain ] = &$noop_translations;
[1410] Fix | Delete
[1411] Fix | Delete
return $noop_translations;
[1412] Fix | Delete
}
[1413] Fix | Delete
[1414] Fix | Delete
/**
[1415] Fix | Delete
* Determines whether there are translations for the text domain.
[1416] Fix | Delete
*
[1417] Fix | Delete
* @since 3.0.0
[1418] Fix | Delete
*
[1419] Fix | Delete
* @global MO[] $l10n An array of all currently loaded text domains.
[1420] Fix | Delete
*
[1421] Fix | Delete
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
[1422] Fix | Delete
* @return bool Whether there are translations.
[1423] Fix | Delete
*/
[1424] Fix | Delete
function is_textdomain_loaded( $domain ) {
[1425] Fix | Delete
global $l10n;
[1426] Fix | Delete
return isset( $l10n[ $domain ] ) && ! $l10n[ $domain ] instanceof NOOP_Translations;
[1427] Fix | Delete
}
[1428] Fix | Delete
[1429] Fix | Delete
/**
[1430] Fix | Delete
* Translates role name.
[1431] Fix | Delete
*
[1432] Fix | Delete
* Since the role names are in the database and not in the source there
[1433] Fix | Delete
* are dummy gettext calls to get them into the POT file and this function
[1434] Fix | Delete
* properly translates them back.
[1435] Fix | Delete
*
[1436] Fix | Delete
* The before_last_bar() call is needed, because older installations keep the roles
[1437] Fix | Delete
* using the old context format: 'Role name|User role' and just skipping the
[1438] Fix | Delete
* content after the last bar is easier than fixing them in the DB. New installations
[1439] Fix | Delete
* won't suffer from that problem.
[1440] Fix | Delete
*
[1441] Fix | Delete
* @since 2.8.0
[1442] Fix | Delete
* @since 5.2.0 Added the `$domain` parameter.
[1443] Fix | Delete
*
[1444] Fix | Delete
* @param string $name The role name.
[1445] Fix | Delete
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
[1446] Fix | Delete
* Default 'default'.
[1447] Fix | Delete
* @return string Translated role name on success, original name on failure.
[1448] Fix | Delete
*/
[1449] Fix | Delete
function translate_user_role( $name, $domain = 'default' ) {
[1450] Fix | Delete
return translate_with_gettext_context( before_last_bar( $name ), 'User role', $domain );
[1451] Fix | Delete
}
[1452] Fix | Delete
[1453] Fix | Delete
/**
[1454] Fix | Delete
* Gets all available languages based on the presence of *.mo and *.l10n.php files in a given directory.
[1455] Fix | Delete
*
[1456] Fix | Delete
* The default directory is WP_LANG_DIR.
[1457] Fix | Delete
*
[1458] Fix | Delete
* @since 3.0.0
[1459] Fix | Delete
* @since 4.7.0 The results are now filterable with the {@see 'get_available_languages'} filter.
[1460] Fix | Delete
* @since 6.5.0 The initial file list is now cached and also takes into account *.l10n.php files.
[1461] Fix | Delete
*
[1462] Fix | Delete
* @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry.
[1463] Fix | Delete
*
[1464] Fix | Delete
* @param string $dir A directory to search for language files.
[1465] Fix | Delete
* Default WP_LANG_DIR.
[1466] Fix | Delete
* @return string[] An array of language codes or an empty array if no languages are present.
[1467] Fix | Delete
* Language codes are formed by stripping the file extension from the language file names.
[1468] Fix | Delete
*/
[1469] Fix | Delete
function get_available_languages( $dir = null ) {
[1470] Fix | Delete
global $wp_textdomain_registry;
[1471] Fix | Delete
[1472] Fix | Delete
$languages = array();
[1473] Fix | Delete
[1474] Fix | Delete
$path = is_null( $dir ) ? WP_LANG_DIR : $dir;
[1475] Fix | Delete
$lang_files = $wp_textdomain_registry->get_language_files_from_path( $path );
[1476] Fix | Delete
[1477] Fix | Delete
if ( $lang_files ) {
[1478] Fix | Delete
foreach ( $lang_files as $lang_file ) {
[1479] Fix | Delete
$lang_file = basename( $lang_file, '.mo' );
[1480] Fix | Delete
$lang_file = basename( $lang_file, '.l10n.php' );
[1481] Fix | Delete
[1482] Fix | Delete
if ( ! str_starts_with( $lang_file, 'continents-cities' ) && ! str_starts_with( $lang_file, 'ms-' ) &&
[1483] Fix | Delete
! str_starts_with( $lang_file, 'admin-' ) ) {
[1484] Fix | Delete
$languages[] = $lang_file;
[1485] Fix | Delete
}
[1486] Fix | Delete
}
[1487] Fix | Delete
}
[1488] Fix | Delete
[1489] Fix | Delete
/**
[1490] Fix | Delete
* Filters the list of available language codes.
[1491] Fix | Delete
*
[1492] Fix | Delete
* @since 4.7.0
[1493] Fix | Delete
*
[1494] Fix | Delete
* @param string[] $languages An array of available language codes.
[1495] Fix | Delete
* @param string $dir The directory where the language files were found.
[1496] Fix | Delete
*/
[1497] Fix | Delete
return apply_filters( 'get_available_languages', array_unique( $languages ), $dir );
[1498] Fix | Delete
}
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function