| 1 |
<?php |
| 2 |
|
| 3 |
class DeepLConfiguration { |
| 4 |
static function getAPIKey() { |
| 5 |
return apply_filters( __CLASS__ . __METHOD__, get_option( 'wpdeepl_api_key' ) ); |
| 6 |
} |
| 7 |
|
| 8 |
static function getMetaBoxPostTypes() { |
| 9 |
return apply_filters( __CLASS__ . __METHOD__, get_option( 'wpdeepl_metabox_post_types' ) ); |
| 10 |
} |
| 11 |
static function getMetaBoxDefaultBehaviour() { |
| 12 |
return apply_filters( __CLASS__ . __METHOD__, get_option( 'wpdeepl_metabox_behaviour' ) ); |
| 13 |
} |
| 14 |
static function getDefaultTargetLanguage() { |
| 15 |
return apply_filters( __CLASS__ . __METHOD__, get_option( 'wpdeepl_default_language' ) ); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* 0 = activated |
| 20 |
* 1 = activated and setup |
| 21 |
*/ |
| 22 |
static function isPluginInstalled() { |
| 23 |
return get_option( 'wpdeepl_plugin_installed' ); |
| 24 |
} |
| 25 |
|
| 26 |
static function execWorks() { |
| 27 |
if( exec( 'echo EXEC' ) == 'EXEC' ){ |
| 28 |
return true; |
| 29 |
} |
| 30 |
return false; |
| 31 |
} |
| 32 |
|
| 33 |
static function DefaultsMetaboxBehaviours() { |
| 34 |
$array = array( |
| 35 |
'replace' => __( 'Replace content', 'wpdeepl' ), |
| 36 |
'append' => __( 'Append to content', 'wpdeepl' ) |
| 37 |
); |
| 38 |
return apply_filters( __CLASS__ . __METHOD__ , $array ); |
| 39 |
} |
| 40 |
static function DefaultsISOCodes() { |
| 41 |
$locale = get_locale(); |
| 42 |
$all_languages = DeepLConfiguration::DefaultsAllLanguages(); |
| 43 |
$languages = array(); |
| 44 |
foreach( $all_languages as $isocode => $labels ) { |
| 45 |
$languages[$isocode] = $labels['labels'][$locale]; |
| 46 |
} |
| 47 |
return apply_filters( __CLASS__ . __METHOD__ , $languages ); |
| 48 |
} |
| 49 |
|
| 50 |
static function DefaultsAllLanguages() { |
| 51 |
$languages = array( |
| 52 |
'FR' => array( |
| 53 |
'labels' => array( |
| 54 |
'fr_FR' => 'français', |
| 55 |
'en_GB' => 'french', |
| 56 |
'de_DE' => 'französisch', |
| 57 |
'es_ES' => 'francés', |
| 58 |
'it_IT' => 'francese', |
| 59 |
'nl_NL' => 'frans', |
| 60 |
'pl_PL' => 'francuski', |
| 61 |
), |
| 62 |
), |
| 63 |
'EN' => array( |
| 64 |
'labels' => array( |
| 65 |
'fr_FR' => 'anglais', |
| 66 |
'en_GB' => 'english', |
| 67 |
'de_DE' => 'englisch', |
| 68 |
'es_ES' => 'inglès', |
| 69 |
'it_IT' => 'inglese', |
| 70 |
'nl_NL' => 'engels', |
| 71 |
'pl_PL' => 'anglik', |
| 72 |
) |
| 73 |
), |
| 74 |
'DE' => array( |
| 75 |
'labels' => array( |
| 76 |
'fr_FR' => 'allemand', |
| 77 |
'en_GB' => 'german', |
| 78 |
'de_DE' => 'deutsch', |
| 79 |
'es_ES' => 'alemán', |
| 80 |
'it_IT' => 'allemando', |
| 81 |
'nl_NL' => 'allemandrijk', |
| 82 |
'pl_PL' => 'niemiec', |
| 83 |
), |
| 84 |
), |
| 85 |
'ES' => array( |
| 86 |
'labels' => array( |
| 87 |
'fr_FR' => 'espagnol', |
| 88 |
'en_GB' => 'spanish', |
| 89 |
'de_DE' => 'spanisch', |
| 90 |
'es_ES' => 'castellano', |
| 91 |
'it_IT' => 'spagnola', |
| 92 |
'nl_NL' => 'spaans', |
| 93 |
'pl_PL' => 'hiszpanin', |
| 94 |
), |
| 95 |
), |
| 96 |
'IT' => array( |
| 97 |
'labels' => array( |
| 98 |
'fr_FR' => 'italien', |
| 99 |
'en_GB' => 'italian', |
| 100 |
'de_DE' => 'italienisch', |
| 101 |
'es_ES' => 'italiano', |
| 102 |
'it_IT' => 'italiano', |
| 103 |
'nl_NL' => 'italiaan', |
| 104 |
'pl_PL' => 'włoch', |
| 105 |
) |
| 106 |
), |
| 107 |
'NL' => array( |
| 108 |
'labels' => array( |
| 109 |
'fr_FR' => 'néerlandais', |
| 110 |
'en_GB' => 'dutch', |
| 111 |
'de_DE' => 'holländisch', |
| 112 |
'es_ES' => 'neerlandés', |
| 113 |
'it_IT' => 'olandese', |
| 114 |
'nl_NL' => 'hollands', |
| 115 |
'pl_PL' => 'holender', |
| 116 |
) |
| 117 |
), |
| 118 |
'PL' => array( |
| 119 |
'labels' => array( |
| 120 |
'fr_FR' => 'polonais', |
| 121 |
'en_GB' => 'polish', |
| 122 |
'de_DE' => 'polnisch', |
| 123 |
'es_ES' => 'polaco', |
| 124 |
'it_IT' => 'polacca', |
| 125 |
'nl_NL' => 'pools', |
| 126 |
'pl_PL' => 'polak', |
| 127 |
) |
| 128 |
), |
| 129 |
); |
| 130 |
return apply_filters( __CLASS__ . __METHOD__, $languages ); |
| 131 |
} |
| 132 |
} |
| 133 |
|
| 134 |
|