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 / Referrer.php

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

61 lines 1.2 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 use Depicter\Utility\Sanitize;
8
9 class Referrer extends ConditionBase
10 {
11 /**
12 * @inheritdoc
13 */
14 public $slug = 'Advanced_Referrer';
15
16 /**
17 * @inheritdoc
18 */
19 public $control = 'comparison';
20
21 /**
22 * @inheritdoc
23 */
24 protected $belongsTo = 'Advanced';
25
26
27 /**
28 * @inheritdoc
29 */
30 public function getLabel(): ?string{
31 return __('Referrer Path', 'depicter' );
32 }
33
34 /**
35 * @inheritDoc
36 */
37 public function getControlOptions(): array{
38 return [];
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' => $_SERVER['HTTP_REFERER'] ? Sanitize::textfield( $_SERVER['HTTP_REFERER'] ) : '',
51 'comparisonFunction' => 'equal',
52 'targetValue' => ''
53 ]);
54
55 $isIncluded = $this->compare( trim( $value['targetParam'], '/'), $value['comparisonFunction'], trim( $value['targetValue'], '/' ) );
56 }
57
58 return $this->selectionMode === 'include' ? $isIncluded : ! $isIncluded;
59 }
60 }
61