PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.3.2
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.3.2
2.7.0 2.6.0 trunk 1.1.0 1.1.4 1.2.1 1.2.2 1.2.3 1.2.5 1.2.9 1.3.1 1.3.2 1.5.0 1.5.1 1.5.4 1.5.7 1.5.8 1.5.9 1.6.2 1.6.5 1.6.8 1.7.2 1.7.4 1.7.5 1.7.9 All 43 releases
sellkit / includes / contact-segmentation / conditions / browser-language.php

browser-language.php in SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster 1.3.2, at includes/contact-segmentation/conditions/browser-language.php

338 lines 10.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sellkit\Contact_Segmentation\Conditions;
4
5 use Sellkit\Contact_Segmentation\Conditions\Condition_Base;
6 use Sellkit\Contact_Segmentation\Operators;
7
8 defined( 'ABSPATH' ) || die();
9
10 /**
11 * Class Browser_Language_Condition
12 *
13 * @package Sellkit\Contact_Segmentation\Conditions
14 * @since 1.1.0
15 */
16 class Browser_Language extends Condition_Base {
17
18 /**
19 * Condition name.
20 *
21 * @since 1.1.0
22 */
23 public function get_name() {
24 return 'browser-language';
25 }
26
27 /**
28 * Condition title.
29 *
30 * @since 1.1.0
31 */
32 public function get_title() {
33 return __( 'Browser Language', 'sellkit' );
34 }
35
36 /**
37 * Condition type.
38 *
39 * @since 1.1.0
40 */
41 public function get_type() {
42 return self::SELLKIT_DROP_DOWN_CONDITION_VALUE;
43 }
44
45 /**
46 * Get the options
47 *
48 * @since 1.1.0
49 * @return string[]
50 */
51 public function get_options() {
52 // It's from here http://www.lingoes.net/en/translator/langcode.htm.
53 return [
54 'aa-DJ' => 'Afar (Djibouti)',
55 'aa-ER' => 'Afar (Eritrea)',
56 'aa-ET' => 'Afar (Ethiopia)',
57 'af-ZA' => 'Afrikaans (South Africa)',
58 'sq-AL' => 'Albanian (Albania)',
59 'sq-MK' => 'Albanian (Macedonia)',
60 'am-ET' => 'Amharic (Ethiopia)',
61 'ar-DZ' => 'Arabic (Algeria)',
62 'ar-BH' => 'Arabic (Bahrain)',
63 'ar-EG' => 'Arabic (Egypt)',
64 'ar-IN' => 'Arabic (India)',
65 'ar-IQ' => 'Arabic (Iraq)',
66 'ar-JO' => 'Arabic (Jordan)',
67 'ar-KW' => 'Arabic (Kuwait)',
68 'ar-LB' => 'Arabic (Lebanon)',
69 'ar-LY' => 'Arabic (Libya)',
70 'ar-MA' => 'Arabic (Morocco)',
71 'ar-OM' => 'Arabic (Oman)',
72 'ar-QA' => 'Arabic (Qatar)',
73 'ar-SA' => 'Arabic (Saudi Arabia)',
74 'ar-SD' => 'Arabic (Sudan)',
75 'ar-SY' => 'Arabic (Syria)',
76 'ar-TN' => 'Arabic (Tunisia)',
77 'ar-AE' => 'Arabic (United Arab Emirates)',
78 'ar-YE' => 'Arabic (Yemen)',
79 'an-ES' => 'Aragonese (Spain)',
80 'hy-AM' => 'Armenian (Armenia)',
81 'as-IN' => 'Assamese (India)',
82 'ast-ES' => 'Asturian (Spain)',
83 'az-AZ' => 'Azerbaijani (Azerbaijan)',
84 'az-TR' => 'Azerbaijani (Turkey)',
85 'eu-FR' => 'Basque (France)',
86 'eu-ES' => 'Basque (Spain)',
87 'be-BY' => 'Belarusian (Belarus)',
88 'bem-ZM' => 'Bemba (Zambia)',
89 'bn-BD' => 'Bengali (Bangladesh)',
90 'bn-IN' => 'Bengali (India)',
91 'ber-DZ' => 'Berber (Algeria)',
92 'ber-MA' => 'Berber (Morocco)',
93 'byn-ER' => 'Blin (Eritrea)',
94 'bs-BA' => 'Bosnian (Bosnia and Herzegovina)',
95 'br-FR' => 'Breton (France)',
96 'bg-BG' => 'Bulgarian (Bulgaria)',
97 'my-MM' => 'Burmese (Myanmar [Burma])',
98 'ca-AD' => 'Catalan (Andorra)',
99 'ca-FR' => 'Catalan (France)',
100 'ca-IT' => 'Catalan (Italy)',
101 'ca-ES' => 'Catalan (Spain)',
102 'zh-CN' => 'Chinese (China)',
103 'zh-HK' => 'Chinese (Hong Kong SAR China)',
104 'zh-SG' => 'Chinese (Singapore)',
105 'zh-TW' => 'Chinese (Taiwan)',
106 'cv-RU' => 'Chuvash (Russia)',
107 'kw-GB' => 'Cornish (United Kingdom)',
108 'crh-UA' => 'Crimean Turkish (Ukraine)',
109 'hr-HR' => 'Croatian (Croatia)',
110 'cs-CZ' => 'Czech (Czech Republic)',
111 'da-DK' => 'Danish (Denmark)',
112 'dv-MV' => 'Divehi (Maldives)',
113 'nl-AW' => 'Dutch (Aruba)',
114 'nl-BE' => 'Dutch (Belgium)',
115 'nl-NL' => 'Dutch (Netherlands)',
116 'dz-BT' => 'Dzongkha (Bhutan)',
117 'en-AG' => 'English (Antigua and Barbuda)',
118 'en-AU' => 'English (Australia)',
119 'en-BW' => 'English (Botswana)',
120 'en-CA' => 'English (Canada)',
121 'en-DK' => 'English (Denmark)',
122 'en-HK' => 'English (Hong Kong SAR China)',
123 'en-IN' => 'English (India)',
124 'en-IE' => 'English (Ireland)',
125 'en-NZ' => 'English (New Zealand)',
126 'en-NG' => 'English (Nigeria)',
127 'en-PH' => 'English (Philippines)',
128 'en-SG' => 'English (Singapore)',
129 'en-ZA' => 'English (South Africa)',
130 'en-GB' => 'English (United Kingdom)',
131 'en-US' => 'English (United States)',
132 'en-ZM' => 'English (Zambia)',
133 'en-ZW' => 'English (Zimbabwe)',
134 'eo' => 'Esperanto',
135 'et-EE' => 'Estonian (Estonia)',
136 'fo-FO' => 'Faroese (Faroe Islands)',
137 'fil-PH' => 'Filipino (Philippines)',
138 'fi-FI' => 'Finnish (Finland)',
139 'fr-BE' => 'French (Belgium)',
140 'fr-CA' => 'French (Canada)',
141 'fr-FR' => 'French (France)',
142 'fr-LU' => 'French (Luxembourg)',
143 'fr-CH' => 'French (Switzerland)',
144 'fur-IT' => 'Friulian (Italy)',
145 'ff-SN' => 'Fulah (Senegal)',
146 'gl-ES' => 'Galician (Spain)',
147 'lg-UG' => 'Ganda (Uganda)',
148 'gez-ER' => 'Geez (Eritrea)',
149 'gez-ET' => 'Geez (Ethiopia)',
150 'ka-GE' => 'Georgian (Georgia)',
151 'de-AT' => 'German (Austria)',
152 'de-BE' => 'German (Belgium)',
153 'de-DE' => 'German (Germany)',
154 'de-LI' => 'German (Liechtenstein)',
155 'de-LU' => 'German (Luxembourg)',
156 'de-CH' => 'German (Switzerland)',
157 'el-CY' => 'Greek (Cyprus)',
158 'el-GR' => 'Greek (Greece)',
159 'gu-IN' => 'Gujarati (India)',
160 'ht-HT' => 'Haitian (Haiti)',
161 'ha-NG' => 'Hausa (Nigeria)',
162 'iw-IL' => 'Hebrew (Israel)',
163 'he-IL' => 'Hebrew (Israel)',
164 'hi-IN' => 'Hindi (India)',
165 'hu-HU' => 'Hungarian (Hungary)',
166 'is-IS' => 'Icelandic (Iceland)',
167 'ig-NG' => 'Igbo (Nigeria)',
168 'id-ID' => 'Indonesian (Indonesia)',
169 'ia' => 'Interlingua',
170 'iu-CA' => 'Inuktitut (Canada)',
171 'ik-CA' => 'Inupiaq (Canada)',
172 'ga-IE' => 'Irish (Ireland)',
173 'it-IT' => 'Italian (Italy)',
174 'it-CH' => 'Italian (Switzerland)',
175 'ja-JP' => 'Japanese (Japan)',
176 'kl-GL' => 'Kalaallisut (Greenland)',
177 'kn-IN' => 'Kannada (India)',
178 'ks-IN' => 'Kashmiri (India)',
179 'csb-PL' => 'Kashubian (Poland)',
180 'kk-KZ' => 'Kazakh (Kazakhstan)',
181 'km-KH' => 'Khmer (Cambodia)',
182 'rw-RW' => 'Kinyarwanda (Rwanda)',
183 'ky-KG' => 'Kirghiz (Kyrgyzstan)',
184 'kok-IN' => 'Konkani (India)',
185 'ko-KR' => 'Korean (South Korea)',
186 'ku-TR' => 'Kurdish (Turkey)',
187 'lo-LA' => 'Lao (Laos)',
188 'lv-LV' => 'Latvian (Latvia)',
189 'li-BE' => 'Limburgish (Belgium)',
190 'li-NL' => 'Limburgish (Netherlands)',
191 'lt-LT' => 'Lithuanian (Lithuania)',
192 'nds-DE' => 'Low German (Germany)',
193 'nds-NL' => 'Low German (Netherlands)',
194 'mk-MK' => 'Macedonian (Macedonia)',
195 'mai-IN' => 'Maithili (India)',
196 'mg-MG' => 'Malagasy (Madagascar)',
197 'ms-MY' => 'Malay (Malaysia)',
198 'ml-IN' => 'Malayalam (India)',
199 'mt-MT' => 'Maltese (Malta)',
200 'gv-GB' => 'Manx (United Kingdom)',
201 'mi-NZ' => 'Maori (New Zealand)',
202 'mr-IN' => 'Marathi (India)',
203 'mn-MN' => 'Mongolian (Mongolia)',
204 'ne-NP' => 'Nepali (Nepal)',
205 'se-NO' => 'Northern Sami (Norway)',
206 'nso-ZA' => 'Northern Sotho (South Africa)',
207 'nb-NO' => 'Norwegian Bokmål (Norway)',
208 'nn-NO' => 'Norwegian Nynorsk (Norway)',
209 'oc-FR' => 'Occitan (France)',
210 'or-IN' => 'Oriya (India)',
211 'om-ET' => 'Oromo (Ethiopia)',
212 'om-KE' => 'Oromo (Kenya)',
213 'os-RU' => 'Ossetic (Russia)',
214 'pap-AN' => 'Papiamento (Netherlands Antilles)',
215 'ps-AF' => 'Pashto (Afghanistan)',
216 'fa-IR' => 'Persian (Iran)',
217 'pl-PL' => 'Polish (Poland)',
218 'pt-BR' => 'Portuguese (Brazil)',
219 'pt-PT' => 'Portuguese (Portugal)',
220 'pa-IN' => 'Punjabi (India)',
221 'pa-PK' => 'Punjabi (Pakistan)',
222 'ro-RO' => 'Romanian (Romania)',
223 'ru-RU' => 'Russian (Russia)',
224 'ru-UA' => 'Russian (Ukraine)',
225 'sa-IN' => 'Sanskrit (India)',
226 'sc-IT' => 'Sardinian (Italy)',
227 'gd-GB' => 'Scottish Gaelic (United Kingdom)',
228 'sr-ME' => 'Serbian (Montenegro)',
229 'sr-RS' => 'Serbian (Serbia)',
230 'sid-ET' => 'Sidamo (Ethiopia)',
231 'sd-IN' => 'Sindhi (India)',
232 'si-LK' => 'Sinhala (Sri Lanka)',
233 'sk-SK' => 'Slovak (Slovakia)',
234 'sl-SI' => 'Slovenian (Slovenia)',
235 'so-DJ' => 'Somali (Djibouti)',
236 'so-ET' => 'Somali (Ethiopia)',
237 'so-KE' => 'Somali (Kenya)',
238 'so-SO' => 'Somali (Somalia)',
239 'nr-ZA' => 'South Ndebele (South Africa)',
240 'st-ZA' => 'Southern Sotho (South Africa)',
241 'es-AR' => 'Spanish (Argentina)',
242 'es-BO' => 'Spanish (Bolivia)',
243 'es-CL' => 'Spanish (Chile)',
244 'es-CO' => 'Spanish (Colombia)',
245 'es-CR' => 'Spanish (Costa Rica)',
246 'es-DO' => 'Spanish (Dominican Republic)',
247 'es-EC' => 'Spanish (Ecuador)',
248 'es-SV' => 'Spanish (El Salvador)',
249 'es-GT' => 'Spanish (Guatemala)',
250 'es-HN' => 'Spanish (Honduras)',
251 'es-MX' => 'Spanish (Mexico)',
252 'es-NI' => 'Spanish (Nicaragua)',
253 'es-PA' => 'Spanish (Panama)',
254 'es-PY' => 'Spanish (Paraguay)',
255 'es-PE' => 'Spanish (Peru)',
256 'es-ES' => 'Spanish (Spain)',
257 'es-US' => 'Spanish (United States)',
258 'es-UY' => 'Spanish (Uruguay)',
259 'es-VE' => 'Spanish (Venezuela)',
260 'sw-KE' => 'Swahili (Kenya)',
261 'sw-TZ' => 'Swahili (Tanzania)',
262 'ss-ZA' => 'Swati (South Africa)',
263 'sv-FI' => 'Swedish (Finland)',
264 'sv-SE' => 'Swedish (Sweden)',
265 'tl-PH' => 'Tagalog (Philippines)',
266 'tg-TJ' => 'Tajik (Tajikistan)',
267 'ta-IN' => 'Tamil (India)',
268 'tt-RU' => 'Tatar (Russia)',
269 'te-IN' => 'Telugu (India)',
270 'th-TH' => 'Thai (Thailand)',
271 'bo-CN' => 'Tibetan (China)',
272 'bo-IN' => 'Tibetan (India)',
273 'tig-ER' => 'Tigre (Eritrea)',
274 'ti-ER' => 'Tigrinya (Eritrea)',
275 'ti-ET' => 'Tigrinya (Ethiopia)',
276 'ts-ZA' => 'Tsonga (South Africa)',
277 'tn-ZA' => 'Tswana (South Africa)',
278 'tr-CY' => 'Turkish (Cyprus)',
279 'tr-TR' => 'Turkish (Turkey)',
280 'tk-TM' => 'Turkmen (Turkmenistan)',
281 'ug-CN' => 'Uighur (China)',
282 'uk-UA' => 'Ukrainian (Ukraine)',
283 'hsb-DE' => 'Upper Sorbian (Germany)',
284 'ur-PK' => 'Urdu (Pakistan)',
285 'uz-UZ' => 'Uzbek (Uzbekistan)',
286 've-ZA' => 'Venda (South Africa)',
287 'vi-VN' => 'Vietnamese (Vietnam)',
288 'wa-BE' => 'Walloon (Belgium)',
289 'cy-GB' => 'Welsh (United Kingdom)',
290 'fy-DE' => 'Western Frisian (Germany)',
291 'fy-NL' => 'Western Frisian (Netherlands)',
292 'wo-SN' => 'Wolof (Senegal)',
293 'xh-ZA' => 'Xhosa (South Africa)',
294 'yi-US' => 'Yiddish (United States)',
295 'yo-NG' => 'Yoruba (Nigeria)',
296 'zu-ZA' => 'Zulu (South Africa)',
297 ];
298 }
299
300 /**
301 * It is pro feature or not.
302 *
303 * @since 1.1.0
304 */
305 public function is_pro() {
306 return false;
307 }
308
309 /**
310 * If it's valid or not.
311 *
312 * @since 1.3.1
313 * @param array $condition_value Condition value.
314 * @param string $operator_name Operator name.
315 * @return bool
316 */
317 public function is_valid( $condition_value, $operator_name ) {
318 if ( empty( $this->data['browser_language'] ) ) {
319 return false;
320 }
321
322 $operator = Operators::$operators[ $operator_name ];
323 $condition = $condition_value;
324
325 if ( strpos( $this->data['browser_language'], '-' ) === false ) {
326 $condition = explode( '-', $condition_value )[0];
327 }
328
329 $is_valid = $operator->is_valid( $this->data['browser_language'], $condition );
330
331 if ( $is_valid ) {
332 return true;
333 }
334
335 return false;
336 }
337 }
338