Server : Apache/2 System : Linux vps.sdns.vn 3.10.0-1160.15.2.el7.x86_64 #1 SMP Wed Feb 3 15:06:38 UTC 2021 x86_64 User : phatdatpq ( 1022) PHP Version : 7.2.34 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/phatdatpq/public_html/wp-content/plugins/loco-translate/src/api/ |
Upload File : |
<?php /** * Third party API helpers */ abstract class Loco_api_Providers { /** * Export API credentials for all supported APIs * @return array[] */ public static function export(){ return apply_filters( 'loco_api_providers', self::builtin() ); } /** * @return array[] */ public static function builtin(){ $settings = Loco_data_Settings::get(); return array ( array ( 'id' => 'deepl', 'name' => 'DeepL Translator', 'key' => $settings->offsetGet('deepl_api_key'), ), array ( 'id' => 'google', 'name' => 'Google Translate', 'key' => $settings->offsetGet('google_api_key'), ), array ( 'id' => 'microsoft', 'name' => 'Microsoft Translator', 'key' => $settings->offsetGet('microsoft_api_key'), 'region' => $settings->offsetGet('microsoft_api_region'), ), array ( 'id' => 'yandex', 'name' => 'Yandex.Translate', 'key' => $settings->offsetGet('yandex_api_key'), ), ); } /** * Get only configured APIs, and sort them fairly * @return array[] */ public static function configured(){ $apis = array_filter( self::export(), array(__CLASS__,'filterConfigured') ); usort( $apis, array(__CLASS__,'compareNames') ); return $apis; } /** * @internal * @param string[] * @return bool */ private static function filterConfigured( array $api ){ return array_key_exists('key',$api) && is_string($api['key']) && '' !== $api['key']; } /** * @internal * @param string[] * @param string[] * @return bool */ private static function compareNames( array $a, array $b ){ return strcasecmp($a['name'],$b['name']); } }