PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.0.4
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.0.4
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
firebox / Inc / Core / FB / Assignments.php

Assignments.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 1.0.4, at Inc/Core/FB/Assignments.php

146 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 1.0.4 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2021 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\FB;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 use FPFramework\Libs\Registry;
20
21 class Assignments
22 {
23 /**
24 * Box
25 *
26 * @var Box
27 */
28 private $box;
29
30 /**
31 * Box Settings
32 *
33 * @var object
34 */
35 private $boxSettings;
36
37 /**
38 * Factory
39 *
40 * @var object
41 */
42 protected $factory;
43
44 /**
45 * Local assignments list
46 *
47 * @var array
48 */
49 private $assignments = [
50 'cookietype|local',
51
52 ];
53
54 /**
55 * Class Constructor
56 *
57 * @param object $item The object to be checked
58 */
59 public function __construct($box, $factory = null)
60 {
61 if (!$box)
62 {
63 return;
64 }
65 $this->box = $box;
66 $this->boxSettings = $this->box->getBoxSettings();
67
68 if (!$factory)
69 {
70 $factory = new \FPFramework\Base\Factory();
71 }
72 $this->factory = $factory;
73 }
74
75 /**
76 * Pass all checks
77 *
78 * @return boolean Returns true if all assignments pass
79 */
80 public function passAll()
81 {
82 $pass = true;
83
84 foreach ($this->assignments as $key => $assignment)
85 {
86 // Break if not passed
87 if (!$pass)
88 {
89 break;
90 }
91
92 $assignmentData = explode('|', $assignment);
93
94 $assignment = $assignmentData[0];
95 $type = isset($assignmentData[1]) ? $assignmentData[1] : '';
96
97 $method = 'pass' . $assignment;
98
99 // Skip item if there is no assosiated method
100 if (!method_exists($this, $method))
101 {
102 continue;
103 }
104
105 $prefix = empty($type) ? 'assignments.' : '';
106
107 $assign = $prefix . 'assign_' . $assignment;
108
109 // Skip item if assignment is missing
110 if (!$this->boxSettings->params->exists($assign) && !$this->boxSettings->params->exists($assign . '_param_type'))
111 {
112 continue;
113 }
114
115 $pass = $this->$method();
116 }
117
118 return $pass;
119 }
120
121 /**
122 * Pass Check for Box Cookie
123 *
124 * @return bool
125 */
126 private function passCookieType()
127 {
128 // Skip if assignment is disabled
129 if ($this->boxSettings->params->get('assign_cookietype') == 'never')
130 {
131 return true;
132 }
133
134 // Skip if box is on Test Mode and a Super User is logged in
135 if ($this->boxSettings->params->get('testmode') && is_user_logged_in() && current_user_can('manage_options'))
136 {
137 return true;
138 }
139
140 $cookie = $this->box->getCookie($this->boxSettings->ID);
141
142 return !$cookie->exist();
143 }
144
145
146 }