PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Rules / Condition / Advanced / Cookie.php

Cookie.php in Depicter — Popup & Slider Builder trunk, at app/src/Rules/Condition/Advanced/Cookie.php

63 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Depicter\Rules\Condition\Advanced;
4
5 use Averta\Core\Utility\Arr;
6 use Depicter\Rules\Condition\Base as ConditionBase;
7
8 class Cookie extends ConditionBase
9 {
10 /**
11 * @inheritdoc
12 */
13 public $slug = 'Advanced_Cookie';
14
15 /**
16 * @inheritdoc
17 */
18 public $control = 'paramComparison';
19
20 /**
21 * @inheritdoc
22 */
23 protected $belongsTo = 'Advanced';
24
25 /**
26 * @inheritdoc
27 */
28 public function getLabel(): ?string{
29 return __('Cookie Value', 'depicter' );
30 }
31
32 /**
33 * @inheritDoc
34 */
35 public function getControlOptions(): array{
36 return [
37 "targetParamPlaceholder" => "cookie_name"
38 ];
39 }
40
41 /**
42 * @inheritdoc
43 */
44 public function check( $value = null ): bool{
45
46 $value = $value ?? $this->value;
47 $isIncluded = empty( $value );
48 if ( ! $isIncluded ) {
49 $value = Arr::merge( $value, [
50 'targetParam' => '',
51 'comparisonFunction' => 'equal',
52 'targetValue' => ''
53 ]);
54
55 if ( !empty( $_COOKIE[ $value['targetParam'] ] ) ) {
56 $isIncluded = $this->compare( $_COOKIE[ $value['targetParam'] ], $value['comparisonFunction'], $value['targetValue'] );
57 }
58 }
59
60 return $this->selectionMode === 'include' ? $isIncluded : ! $isIncluded;
61 }
62 }
63