PluginProbe
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster / 2.7.0
SellKit – Funnel builder and checkout optimizer for WooCommerce to sell more, faster v2.7.0
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
← All changes | includes/contact-segmentation/conditions/browser-language.php +40 -0 1.2.52.7.0 View file →
@@ -2,8 +2,9 @@
2 2
3 3 namespace Sellkit\Contact_Segmentation\Conditions;
4 4
5 5 use Sellkit\Contact_Segmentation\Conditions\Condition_Base;
6 +use Sellkit\Contact_Segmentation\Operators;
6 7
7 8 defined( 'ABSPATH' ) || die();
8 9
9 10 /**
@@ -47,8 +48,18 @@
47 48 * @since 1.1.0
48 49 * @return string[]
49 50 */
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() {
51 62 // It's from here http://www.lingoes.net/en/translator/langcode.htm.
52 63 return [
53 64 'aa-DJ' => 'Afar (Djibouti)',
54 65 'aa-ER' => 'Afar (Eritrea)',
@@ -301,7 +312,36 @@
301 312 *
302 313 * @since 1.1.0
303 314 */
304 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 +
305 345 return false;
306 346 }
307 347 }