PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.1.1
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.1.1
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.1.1, at Inc/Core/FB/Assignments.php

143 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.1.1 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2022 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 Class Instance
25 *
26 * @var Box
27 */
28 private $box_instance;
29
30 /**
31 * Box Object
32 *
33 * @var Object
34 */
35 private $box;
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 $box_instance The Box Class Instance
58 * @param object $factory The Framework Class Instance
59 *
60 * @return void
61 */
62 public function __construct($box_instance = null, $factory = null)
63 {
64 $this->box_instance = $box_instance;
65 $this->box = $this->box_instance->getBox();
66
67 if (!$factory)
68 {
69 $factory = new \FPFramework\Base\Factory();
70 }
71 $this->factory = $factory;
72 }
73
74 /**
75 * Pass all checks
76 *
77 * @return boolean Returns true if all assignments pass
78 */
79 public function passAll()
80 {
81 $pass = true;
82
83 foreach ($this->assignments as $key => $assignment)
84 {
85 // Break if not passed
86 if (!$pass)
87 {
88 break;
89 }
90
91 $assignmentData = explode('|', $assignment);
92
93 $assignment = $assignmentData[0];
94 $type = isset($assignmentData[1]) ? $assignmentData[1] : '';
95
96 $method = 'pass' . $assignment;
97
98 // Skip item if there is no assosiated method
99 if (!method_exists($this, $method))
100 {
101 continue;
102 }
103
104 $prefix = empty($type) ? 'assignments.' : '';
105
106 $assign = $prefix . 'assign_' . $assignment;
107
108 // Skip item if assignment is missing
109 if (!$this->box->params->exists($assign) && !$this->box->params->exists($assign . '_param_type'))
110 {
111 continue;
112 }
113
114 $pass = $this->$method();
115 }
116
117 return $pass;
118 }
119
120 /**
121 * Pass Check for Box Cookie
122 *
123 * @return bool
124 */
125 private function passCookieType()
126 {
127 // Skip if assignment is disabled
128 if ($this->box->params->get('assign_cookietype') == 'never')
129 {
130 return true;
131 }
132
133 // Skip if box is on Test Mode and a Super User is logged in
134 if ($this->box->params->get('testmode') && is_user_logged_in() && current_user_can('manage_options'))
135 {
136 return true;
137 }
138
139 return !$this->box_instance->getCookie()->exist();
140 }
141
142
143 }