PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / trunk
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar vtrunk
3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 All 156 releases
← All changes | includes/Types/NotificationBar.php +13 -54 3.2.8trunk View file →
@@ -71,9 +71,12 @@
71 71 if ($settings['bar_reappearance'] === 'show_welcomebar_next_visit' &&
72 72 isset($_COOKIE[$cookie_name]) &&
73 73 $_COOKIE[$cookie_name] === 'shown' &&
74 74 !empty($_SERVER['HTTP_REFERER']) &&
75 - strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) !== false) {
75 + strpos(
76 + esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER'])),
77 + isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : ''
78 + ) !== false) {
76 79 return true;
77 80 }
78 81 }
79 82
@@ -85,10 +88,10 @@
85 88 if ($settings['schedule_type'] === 'daily' &&
86 89 !empty($settings['daily_from_time']) &&
87 90 !empty($settings['daily_to_time'])) {
88 91
89 - $from_time = strtotime(date('Y-m-d ') . date('H:i:s', strtotime($settings['daily_from_time'])));
90 - $to_time = strtotime(date('Y-m-d ') . date('H:i:s', strtotime($settings['daily_to_time'])));
92 + $from_time = strtotime(gmdate('Y-m-d ') . gmdate('H:i:s', strtotime($settings['daily_from_time'])));
93 + $to_time = strtotime(gmdate('Y-m-d ') . gmdate('H:i:s', strtotime($settings['daily_to_time'])));
91 94
92 95 // Handle case where to_time is on the next day
93 96 if ($to_time < $from_time) {
94 97 $to_time += 86400; // Add 24 hours
@@ -104,11 +107,11 @@
104 107 !empty($settings['weekly_days']) &&
105 108 !empty($settings['weekly_from_time']) &&
106 109 !empty($settings['weekly_to_time'])) {
107 110
108 - $current_day = strtolower(date('l', $current_time));
109 - $from_time = strtotime(date('Y-m-d ') . date('H:i:s', strtotime($settings['weekly_from_time'])));
110 - $to_time = strtotime(date('Y-m-d ') . date('H:i:s', strtotime($settings['weekly_to_time'])));
111 + $current_day = strtolower(gmdate('l', $current_time));
112 + $from_time = strtotime(gmdate('Y-m-d ') . gmdate('H:i:s', strtotime($settings['weekly_from_time'])));
113 + $to_time = strtotime(gmdate('Y-m-d ') . gmdate('H:i:s', strtotime($settings['weekly_to_time'])));
111 114
112 115 // Handle case where to_time is on the next day
113 116 if ($to_time < $from_time) {
114 117 $to_time += 86400; // Add 24 hours
@@ -146,10 +149,10 @@
146 149 return true;
147 150 }
148 151
149 152 // Combine current date with from/to times
150 - $from_time = strtotime(date('Y-m-d ') . date('H:i:s', strtotime($custom_from_time)));
151 - $to_time = strtotime(date('Y-m-d ') . date('H:i:s', strtotime($custom_to_time)));
153 + $from_time = strtotime(gmdate('Y-m-d ') . gmdate('H:i:s', strtotime($custom_from_time)));
154 + $to_time = strtotime(gmdate('Y-m-d ') . gmdate('H:i:s', strtotime($custom_to_time)));
152 155
153 156 // Handle overnight time ranges (e.g., 10 PM - 6 AM)
154 157 if ($to_time < $from_time) {
155 158 $to_time += 86400; // add 24 hours
@@ -164,54 +167,10 @@
164 167 }
165 168 }
166 169 }
167 170
168 - // 3. Country Targeting
169 - if ( !empty($settings['country_targeting']) && is_array($settings['country_targeting']) && !in_array('all', $settings['country_targeting'])) {
170 - $visitor_country = Helper::nx_get_visitor_country_code();
171 - // If we couldn't determine the country or it's not in the target list
172 - $countryValues = array_column( $settings['country_targeting'], 'value' );
173 - $normalizedCountries = array_map('strtoupper', $countryValues);
174 - $visitor_country = strtoupper($visitor_country);
175 - if (empty($visitor_country)) {
176 - return true;
177 - }
178 - // Only apply country filtering if 'ALL' is not in the list
179 - if (!in_array('ALL', $normalizedCountries)) {
180 - if (empty($visitor_country) || !in_array($visitor_country, $normalizedCountries)) {
181 - return true;
182 - }
183 - }
184 - }
185 -
186 - // 4. User Role Targeting
187 - if (!empty($settings['targeting_user_roles']) &&
188 - !in_array('all_users', $settings['targeting_user_roles'])) {
189 -
190 - // For logged out users
191 - if (!is_user_logged_in() && !in_array('guest', $settings['targeting_user_roles'])) {
192 - return true;
193 - }
194 -
195 - // For logged in users
196 - if (is_user_logged_in()) {
197 - $user = wp_get_current_user();
198 - $user_roles = (array) $user->roles;
199 -
200 - // Check if any of the user's roles match the targeted roles
201 - $has_targeted_role = false;
202 - foreach ($user_roles as $role) {
203 - if (in_array($role, $settings['targeting_user_roles'])) {
204 - $has_targeted_role = true;
205 - break;
206 - }
207 - }
208 -
209 - if (!$has_targeted_role) {
210 - return true;
211 - }
212 - }
213 - }
171 + // Country & user-role targeting are enforced globally for every type in
172 + // NotificationX\Core\Targeting (also hooked on nx_show_on_exclude).
214 173
215 174 // If we've made it here, don't exclude the notification
216 175 return $exclude;
217 176 }