PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 1.7.4
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v1.7.4
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 1.8.1 All 42 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.7.4, at includes/contact-segmentation/conditions/browser-language.php

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