| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.7 Free | |
| 4 | + * @version 2.1.4 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2024 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FireBox\Core\FB; |
| @@ -116,9 +116,9 @@ | ||
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | $payload = [ |
| 119 | 119 | 'where' => [ |
| 120 | - 'ID' => ' = ' . intval($id), | |
| 120 | + 'ID' => ' = ' . esc_sql(intval($id)), | |
| 121 | 121 | 'post_type' => " = 'firebox'" |
| 122 | 122 | ] |
| 123 | 123 | ]; |
| 124 | 124 | |
| @@ -124,9 +124,9 @@ | ||
| 124 | 124 | |
| 125 | 125 | // apply status if given |
| 126 | 126 | if ($status) |
| 127 | 127 | { |
| 128 | - $payload['where']['post_status'] = ' = \'' . sanitize_key($status) . '\''; | |
| 128 | + $payload['where']['post_status'] = ' = \'' . esc_sql($status) . '\''; | |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | if (!$box = firebox()->tables->box->getResults($payload)) |
| 132 | 132 | { |
| @@ -156,18 +156,13 @@ | ||
| 156 | 156 | { |
| 157 | 157 | // Check Publishing Assignments |
| 158 | 158 | if (!$this->pass()) |
| 159 | 159 | { |
| 160 | - return false; | |
| 160 | + return; | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $fbox = $this->box; |
| 164 | - | |
| 165 | - /** | |
| 166 | - * Runs before rendering the box. | |
| 167 | - */ | |
| 168 | - $this->box = apply_filters('firebox/box/before_render', $this->box); | |
| 169 | - | |
| 164 | + | |
| 170 | 165 | $this->prepare(); |
| 171 | 166 | |
| 172 | 167 | $css = $this->getCustomCSS(); |
| 173 | 168 | |
| @@ -183,56 +178,13 @@ | ||
| 183 | 178 | |
| 184 | 179 | |
| 185 | 180 | }); |
| 186 | 181 | |
| 187 | - // Allow to manipulate the box before rendering | |
| 188 | - $this->box = apply_filters('firebox/box/edit', $this->box); | |
| 189 | - | |
| 190 | - // payload | |
| 191 | - $payload = [ | |
| 192 | - 'box' => $this->box, | |
| 193 | - 'params' => $this->params, | |
| 194 | - ]; | |
| 195 | - | |
| 196 | - // print campaign HTML | |
| 197 | - add_action('wp_footer', function() use ($payload) { | |
| 198 | - echo $this->getFinalCampaignHTML($payload); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 199 | - }); | |
| 200 | - | |
| 201 | - return true; | |
| 202 | - } | |
| 203 | - | |
| 204 | - public function renderEmbed() | |
| 205 | - { | |
| 206 | - // Check Publishing Assignments | |
| 207 | - if (!$this->pass()) | |
| 208 | - { | |
| 209 | - return false; | |
| 210 | - } | |
| 211 | - | |
| 212 | 182 | /** |
| 213 | 183 | * Runs before rendering the box. |
| 214 | 184 | */ |
| 215 | - $this->box = apply_filters('firebox/box/before_render', $this->box); | |
| 185 | + do_action('firebox/box/before_render', $this->box); | |
| 216 | 186 | |
| 217 | - $this->prepare(); | |
| 218 | - | |
| 219 | - // Loads all media files. | |
| 220 | - $this->loadBoxMedia($this->box); | |
| 221 | - | |
| 222 | - $css = $this->getCustomCSS(); | |
| 223 | - | |
| 224 | - wp_register_style('fireboxStyle', false); | |
| 225 | - wp_enqueue_style('fireboxStyle'); | |
| 226 | - | |
| 227 | - // Load CSS | |
| 228 | - if ($css) | |
| 229 | - { | |
| 230 | - wp_add_inline_style('fireboxStyle', $css); | |
| 231 | - } | |
| 232 | - | |
| 233 | - | |
| 234 | - | |
| 235 | 187 | // Allow to manipulate the box before rendering |
| 236 | 188 | $this->box = apply_filters('firebox/box/edit', $this->box); |
| 237 | 189 | |
| 238 | 190 | // payload |
| @@ -239,29 +191,21 @@ | ||
| 239 | 191 | $payload = [ |
| 240 | 192 | 'box' => $this->box, |
| 241 | 193 | 'params' => $this->params, |
| 242 | 194 | ]; |
| 243 | - | |
| 195 | + | |
| 244 | 196 | // return box template |
| 245 | - return $this->getFinalCampaignHTML($payload); | |
| 197 | + add_action('wp_footer', function() use ($payload) { | |
| 198 | + echo firebox()->renderer->public->render('box', $payload, true); | |
| 199 | + }); | |
| 246 | 200 | } |
| 247 | 201 | |
| 248 | - public function getFinalCampaignHTML($payload) | |
| 249 | - { | |
| 250 | - $html = firebox()->renderer->public->render('box', $payload, true); | |
| 251 | - | |
| 252 | - /** | |
| 253 | - * Runs after rendering the box. | |
| 254 | - */ | |
| 255 | - return apply_filters('firebox/box/after_render', $html, $payload['box']); | |
| 256 | - } | |
| 257 | - | |
| 258 | 202 | /** |
| 259 | 203 | * Gets the Custom CSS of the popup. |
| 260 | 204 | * |
| 261 | 205 | * @return string |
| 262 | 206 | */ |
| 263 | - public function getCustomCSS() | |
| 207 | + private function getCustomCSS() | |
| 264 | 208 | { |
| 265 | 209 | return $this->box->params->get('customcss', ''); |
| 266 | 210 | } |
| 267 | 211 | |
| @@ -277,16 +221,16 @@ | ||
| 277 | 221 | return; |
| 278 | 222 | } |
| 279 | 223 | self::$loadedLocalizedScript = true; |
| 280 | 224 | |
| 281 | - $data = [ | |
| 282 | - 'ajax_url' => admin_url('admin-ajax.php'), | |
| 283 | - 'nonce' => wp_create_nonce('fbox_js_nonce'), | |
| 284 | - 'site_url' => site_url('/'), | |
| 285 | - 'referrer' => isset($_SERVER['HTTP_REFERER']) ? sanitize_url(wp_unslash($_SERVER['HTTP_REFERER'])) : '' | |
| 286 | - ]; | |
| 225 | + $data = array( | |
| 226 | + 'ajax_url' => admin_url('admin-ajax.php'), | |
| 227 | + 'nonce' => wp_create_nonce('fbox_js_nonce'), | |
| 228 | + 'site_url' => site_url('/'), | |
| 229 | + 'referrer' => isset($_SERVER['HTTP_REFERER']) ? sanitize_text_field($_SERVER['HTTP_REFERER']) : '' | |
| 230 | + ); | |
| 287 | 231 | |
| 288 | - wp_add_inline_script('firebox-main', 'const fbox_js_object = ' . wp_json_encode($data), 'before'); | |
| 232 | + wp_localize_script('firebox', 'fbox_js_object', $data); | |
| 289 | 233 | } |
| 290 | 234 | |
| 291 | 235 | /** |
| 292 | 236 | * Load Box Media |
| @@ -296,29 +240,66 @@ | ||
| 296 | 240 | public function loadBoxMedia($box) |
| 297 | 241 | { |
| 298 | 242 | $box = new Registry($box); |
| 299 | 243 | |
| 300 | - wp_enqueue_style( | |
| 301 | - 'firebox-animations', | |
| 302 | - FBOX_MEDIA_PUBLIC_URL . 'css/vendor/animate.min.css', | |
| 303 | - [], | |
| 304 | - FBOX_VERSION | |
| 305 | - ); | |
| 244 | + // Add polyfills for Internet Explorer | |
| 245 | + $browser = $this->factory->getBrowser(); | |
| 246 | + if ($browser && is_array($browser) && array_key_exists('name', $browser) && $browser['name'] === 'ie') | |
| 247 | + { | |
| 248 | + wp_enqueue_script( | |
| 249 | + 'firebox-ie11-polyfill', | |
| 250 | + 'https://polyfill.io/v3/polyfill.min.js?features=NodeList.prototype.forEach%2CElement.prototype.closest%2CArray.prototype.forEach%2CArray.prototype.find%2CIntersectionObserver%2CIntersectionObserverEntry', | |
| 251 | + [], | |
| 252 | + FBOX_VERSION, | |
| 253 | + true | |
| 254 | + ); | |
| 255 | + } | |
| 306 | 256 | |
| 307 | 257 | /** |
| 308 | - * FireBox JS | |
| 258 | + * Velocity | |
| 309 | 259 | */ |
| 310 | - wp_enqueue_script('firebox-main'); | |
| 260 | + if ($this->params->get('loadVelocity', true)) | |
| 261 | + { | |
| 262 | + wp_enqueue_script( | |
| 263 | + 'firebox-velocity', | |
| 264 | + FBOX_MEDIA_PUBLIC_URL . 'js/vendor/velocity.js', | |
| 265 | + [], | |
| 266 | + FBOX_VERSION, | |
| 267 | + true | |
| 268 | + ); | |
| 269 | + wp_enqueue_script( | |
| 270 | + 'firebox-velocity-ui', | |
| 271 | + FBOX_MEDIA_PUBLIC_URL . 'js/vendor/velocity.ui.js', | |
| 272 | + [], | |
| 273 | + FBOX_VERSION, | |
| 274 | + true | |
| 275 | + ); | |
| 311 | 276 | |
| 312 | - | |
| 277 | + /** | |
| 278 | + * Animations | |
| 279 | + */ | |
| 280 | + if (strpos($box->get('params.data.animationin'), 'firebox') !== false || strpos($box->get('params.data.animationout'), 'firebox') !== false) | |
| 281 | + { | |
| 282 | + wp_enqueue_script( | |
| 283 | + 'firebox-animations', | |
| 284 | + FBOX_MEDIA_PUBLIC_URL . 'js/animations.js', | |
| 285 | + [], | |
| 286 | + FBOX_VERSION, | |
| 287 | + true | |
| 288 | + ); | |
| 289 | + } | |
| 290 | + } | |
| 313 | 291 | |
| 314 | - // Add Custom Javascript | |
| 315 | - $custom_code = $box->get('params.data.customcode', ''); | |
| 316 | - if (is_string($custom_code) && !empty($custom_code)) | |
| 317 | - { | |
| 318 | - $custom_code = html_entity_decode(stripslashes($custom_code)); | |
| 319 | - wp_add_inline_script('firebox-main', $custom_code, 'after'); | |
| 320 | - } | |
| 292 | + /** | |
| 293 | + * FireBox JS | |
| 294 | + */ | |
| 295 | + wp_enqueue_script( | |
| 296 | + 'firebox', | |
| 297 | + FBOX_MEDIA_PUBLIC_URL . 'js/firebox.js', | |
| 298 | + [], | |
| 299 | + FBOX_VERSION, | |
| 300 | + true | |
| 301 | + ); | |
| 321 | 302 | |
| 322 | 303 | // run above the main JS script to run only once |
| 323 | 304 | self::setJSObject(); |
| 324 | 305 | |
| @@ -324,14 +305,17 @@ | ||
| 324 | 305 | |
| 325 | 306 | /** |
| 326 | 307 | * FireBox CSS |
| 327 | 308 | */ |
| 328 | - wp_enqueue_style( | |
| 329 | - 'firebox', | |
| 330 | - FBOX_MEDIA_PUBLIC_URL . 'css/firebox.css', | |
| 331 | - [], | |
| 332 | - FBOX_VERSION | |
| 333 | - ); | |
| 309 | + if ($this->params->get('loadCSS', true)) | |
| 310 | + { | |
| 311 | + wp_enqueue_style( | |
| 312 | + 'firebox', | |
| 313 | + FBOX_MEDIA_PUBLIC_URL . 'css/firebox.css', | |
| 314 | + [], | |
| 315 | + FBOX_VERSION | |
| 316 | + ); | |
| 317 | + } | |
| 334 | 318 | |
| 335 | 319 | /** |
| 336 | 320 | * Page Slide mode JS |
| 337 | 321 | */ |
| @@ -339,9 +323,9 @@ | ||
| 339 | 323 | { |
| 340 | 324 | wp_enqueue_script( |
| 341 | 325 | 'firebox-pageslide-mode', |
| 342 | 326 | FBOX_MEDIA_PUBLIC_URL . 'js/pageslide_mode.js', |
| 343 | - ['firebox-main'], | |
| 327 | + [], | |
| 344 | 328 | FBOX_VERSION, |
| 345 | 329 | true |
| 346 | 330 | ); |
| 347 | 331 | } |
| @@ -346,11 +330,43 @@ | ||
| 346 | 330 | ); |
| 347 | 331 | } |
| 348 | 332 | |
| 349 | 333 | |
| 334 | + | |
| 335 | + $this->loadThemeCSSOverrides(); | |
| 350 | 336 | } |
| 351 | 337 | |
| 352 | 338 | /** |
| 339 | + * Some themes require overrides to preserve as much as we can the styling of the popups. | |
| 340 | + * | |
| 341 | + * @return void | |
| 342 | + */ | |
| 343 | + private function loadThemeCSSOverrides() | |
| 344 | + { | |
| 345 | + $active_theme = wp_get_theme(); | |
| 346 | + $theme = $active_theme->template; | |
| 347 | + | |
| 348 | + /** | |
| 349 | + * This is the listed of the themes that we have created overrides | |
| 350 | + */ | |
| 351 | + $themes = [ | |
| 352 | + 'twentytwentyone' | |
| 353 | + ]; | |
| 354 | + | |
| 355 | + if (!in_array($theme, $themes)) | |
| 356 | + { | |
| 357 | + return; | |
| 358 | + } | |
| 359 | + | |
| 360 | + wp_enqueue_style( | |
| 361 | + 'firebox-theme-' . $theme . '-override', | |
| 362 | + FBOX_MEDIA_PUBLIC_URL . 'css/themes/' . $theme . '.css', | |
| 363 | + [], | |
| 364 | + FBOX_VERSION | |
| 365 | + ); | |
| 366 | + } | |
| 367 | + | |
| 368 | + /** | |
| 353 | 369 | * Prepares the box before rendering |
| 354 | 370 | * |
| 355 | 371 | * @return void |
| 356 | 372 | */ |
| @@ -355,39 +371,30 @@ | ||
| 355 | 371 | * @return void |
| 356 | 372 | */ |
| 357 | 373 | public function prepare() |
| 358 | 374 | { |
| 359 | - remove_filter('the_content', 'wptexturize'); | |
| 375 | + $this->css = new Styling\CSS($this->box); | |
| 360 | 376 | |
| 361 | 377 | $cParam = BoxHelper::getParams(); |
| 362 | 378 | $cParam = new Registry($cParam); |
| 363 | 379 | |
| 364 | 380 | $this->box->post_content = apply_filters('the_content', $this->box->post_content); |
| 365 | - | |
| 366 | - $mode = $this->box->params->get('mode'); | |
| 367 | 381 | |
| 382 | + $position = $this->box->params->get('position', ''); | |
| 383 | + $position = !is_string($position) ? '' : $position; | |
| 384 | + | |
| 368 | 385 | /* Classes */ |
| 369 | 386 | $css_class = [ |
| 370 | 387 | $this->box->ID, |
| 371 | - $mode | |
| 388 | + $position | |
| 372 | 389 | ]; |
| 390 | + | |
| 391 | + $rtl = $this->box->params->get('rtl', '0'); | |
| 392 | + if ($rtl == '1') | |
| 393 | + { | |
| 394 | + $css_class[] = 'rtl'; | |
| 395 | + } | |
| 373 | 396 | |
| 374 | - if (in_array($mode, ['popup', 'stickybar', 'sidebar', 'floating', 'slide-in'])) | |
| 375 | - { | |
| 376 | - $position = $this->box->params->get('position', ''); | |
| 377 | - $position = !is_string($position) ? '' : $position; | |
| 378 | - if ($position) | |
| 379 | - { | |
| 380 | - $css_class[] = $position; | |
| 381 | - } | |
| 382 | - } | |
| 383 | - else if ($mode === 'fullscreen') | |
| 384 | - { | |
| 385 | - if ($center_content = $this->box->params->get('center_content', false)) { | |
| 386 | - $css_class[] = 'center-content'; | |
| 387 | - } | |
| 388 | - } | |
| 389 | - | |
| 390 | 397 | self::prefixCSSClasses($css_class); |
| 391 | 398 | |
| 392 | 399 | // Class suffix |
| 393 | 400 | $classSuffix = $this->box->params->get('classsuffix', ''); |
| @@ -396,12 +403,13 @@ | ||
| 396 | 403 | $css_class[] = $classSuffix; |
| 397 | 404 | |
| 398 | 405 | $this->box->classes = $css_class; |
| 399 | 406 | |
| 400 | - // Dialog CSS Classes | |
| 407 | + // Box shadow | |
| 408 | + $boxshadow = (is_string($this->box->params->get('boxshadow', '1')) || is_int($this->box->params->get('boxshadow', '1'))) ? $this->box->params->get('boxshadow', '1') : '0'; | |
| 409 | + | |
| 401 | 410 | $dialog_css_classes = [ |
| 402 | - // Add Box shadow | |
| 403 | - $this->box->params->get('boxshadow') ? 'shdelevation' : null | |
| 411 | + $boxshadow != '0' ? 'shd' . $boxshadow : null | |
| 404 | 412 | ]; |
| 405 | 413 | |
| 406 | 414 | // Align Content |
| 407 | 415 | $aligncontent = is_string($this->box->params->get('aligncontent')) ? explode(' ', $this->box->params->get('aligncontent')) : []; |
| @@ -410,8 +418,9 @@ | ||
| 410 | 418 | self::prefixCSSClasses($dialog_css_classes); |
| 411 | 419 | $this->box->dialog_classes = $dialog_css_classes; |
| 412 | 420 | |
| 413 | 421 | $trigger_point_methods = [ |
| 422 | + 'pageready' => 'onPageReady', | |
| 414 | 423 | 'pageload' => 'onPageLoad', |
| 415 | 424 | 'onclick' => 'onClick', |
| 416 | 425 | 'elementHover' => 'onHover', |
| 417 | 426 | 'ondemand' => 'onDemand', |
| @@ -418,15 +427,13 @@ | ||
| 418 | 427 | |
| 419 | 428 | ]; |
| 420 | 429 | |
| 421 | 430 | /* Other Settings */ |
| 422 | - $this->box->params->set('animation_duration', $this->box->params->get('animation_duration', 0.2)); | |
| 431 | + $scroll_depth = $this->box->params->get('scroll_depth', 'percentage'); | |
| 432 | + $scroll_depth = is_string($scroll_depth) ? $scroll_depth : ''; | |
| 423 | 433 | |
| 424 | - $scroll_amount = $this->box->params->get('scroll_amount', '80%'); | |
| 434 | + $animation_duration = $this->box->params->get('duration') ? (float) $this->box->params->get('duration') : 0; | |
| 425 | 435 | |
| 426 | - // Parse scroll_amount to extract unit and value | |
| 427 | - $scroll_amount_data = $this->parseScrollAmount($scroll_amount); | |
| 428 | - | |
| 429 | 436 | $delay = in_array($this->box->params->get('triggermethod'), ['floatingbutton', 'onexternallink']) ? 0 : (int) $this->box->params->get('triggerdelay') * 1000; |
| 430 | 437 | |
| 431 | 438 | $trigger_method = (is_string($this->box->params->get('triggermethod'))) && array_key_exists($this->box->params->get('triggermethod'), $trigger_point_methods) ? $trigger_point_methods[$this->box->params->get('triggermethod')] : $this->box->params->get('triggermethod'); |
| 432 | 439 | |
| @@ -438,13 +445,12 @@ | ||
| 438 | 445 | 'trigger' => $trigger_method, |
| 439 | 446 | 'trigger_selector' => $trigger_method === 'onExternalLink' ? '' : rtrim($trigger_element, ','), |
| 440 | 447 | 'delay' => $delay, |
| 441 | 448 | |
| 442 | - 'close_on_esc' => (bool) $this->box->params->get('close_on_esc', false), | |
| 443 | 449 | 'animation_open' => $this->box->params->get('animationin'), |
| 444 | 450 | 'animation_close' => $this->box->params->get('animationout'), |
| 445 | - 'animation_duration' => (float) $this->box->params->get('animation_duration') * 1000, | |
| 446 | - 'prevent_default' => true, | |
| 451 | + 'animation_duration' => (float) $animation_duration * 1000, | |
| 452 | + 'prevent_default' => (bool) $this->box->params->get('preventdefault', true), | |
| 447 | 453 | 'backdrop' => (bool) $this->box->params->get('overlay'), |
| 448 | 454 | 'backdrop_color' => $this->box->params->get('overlay_color'), |
| 449 | 455 | 'backdrop_click' => (bool) $this->box->params->get('overlayclick'), |
| 450 | 456 | 'disable_page_scroll' => (bool) $this->box->params->get('preventpagescroll'), |
| @@ -449,54 +455,18 @@ | ||
| 449 | 455 | 'backdrop_click' => (bool) $this->box->params->get('overlayclick'), |
| 450 | 456 | 'disable_page_scroll' => (bool) $this->box->params->get('preventpagescroll'), |
| 451 | 457 | 'test_mode' => (bool) $this->box->params->get('testmode'), |
| 452 | 458 | 'debug' => (bool) $cParam->get('debug', false), |
| 453 | - 'auto_focus' => (bool) $this->box->params->get('autofocus', false), | |
| 454 | - 'mode' => $this->box->params->get('mode') | |
| 459 | + 'auto_focus' => (bool) $this->box->params->get('autofocus', false) | |
| 455 | 460 | ]; |
| 456 | 461 | |
| 457 | - $this->css = new Styling\CSS($this->box); | |
| 458 | - | |
| 459 | 462 | // Apply Popup CSS |
| 460 | 463 | $this->box->params->set('customcss', $this->box->params->get('customcss') . $this->css->getCSS()); |
| 461 | 464 | |
| 462 | 465 | $this->replaceBoxSmartTags(); |
| 463 | - | |
| 464 | - add_filter('the_content', 'wptexturize'); | |
| 465 | 466 | } |
| 466 | 467 | |
| 467 | 468 | /** |
| 468 | - * Parses scroll_amount to extract unit and value | |
| 469 | - * | |
| 470 | - * @param mixed $scroll_amount | |
| 471 | - * | |
| 472 | - * @return array | |
| 473 | - */ | |
| 474 | - private function parseScrollAmount($scroll_amount) | |
| 475 | - { | |
| 476 | - if (is_array($scroll_amount)) | |
| 477 | - { | |
| 478 | - return [ | |
| 479 | - 'unit' => $scroll_amount['unit'] ?? '%', | |
| 480 | - 'value' => $scroll_amount['value'] ?? 80 | |
| 481 | - ]; | |
| 482 | - } | |
| 483 | - | |
| 484 | - if (is_string($scroll_amount) && preg_match('/^(\d+)(px|%)$/', $scroll_amount, $matches)) | |
| 485 | - { | |
| 486 | - return [ | |
| 487 | - 'unit' => $matches[2], | |
| 488 | - 'value' => $matches[1] | |
| 489 | - ]; | |
| 490 | - } | |
| 491 | - | |
| 492 | - return [ | |
| 493 | - 'unit' => '%', | |
| 494 | - 'value' => 80 | |
| 495 | - ]; | |
| 496 | - } | |
| 497 | - | |
| 498 | - /** | |
| 499 | 469 | * Replaces all box smart tags |
| 500 | 470 | * |
| 501 | 471 | * @return object |
| 502 | 472 | */ |
| @@ -542,12 +512,11 @@ | ||
| 542 | 512 | $this->box->params->merge(self::getAssignmentsForMirroring($mirror_box_id)); |
| 543 | 513 | } |
| 544 | 514 | |
| 545 | 515 | // Get a recursive array of all rules |
| 546 | - $rules = $this->box->params->get('rules', []); | |
| 547 | - $rules = is_string($rules) ? json_decode($rules, true) : json_decode(wp_json_encode($rules), true); | |
| 516 | + $rules = json_decode(json_encode($this->box->params->get('rules', [])), true); | |
| 548 | 517 | |
| 549 | - // If testmode is enabled disable the User Groups condition | |
| 518 | + // If testmode is enabled disable the User Groups assignment | |
| 550 | 519 | if ($this->box->params->get('testmode')) |
| 551 | 520 | { |
| 552 | 521 | foreach ($rules as $key => &$group) |
| 553 | 522 | { |
| @@ -565,14 +534,14 @@ | ||
| 565 | 534 | } |
| 566 | 535 | } |
| 567 | 536 | } |
| 568 | 537 | |
| 569 | - // Check framework based conditions | |
| 538 | + // Check framework based assignments | |
| 570 | 539 | return \FPFramework\Base\Conditions\ConditionBuilder::pass($rules, $this->factory); |
| 571 | 540 | } |
| 572 | 541 | |
| 573 | 542 | /** |
| 574 | - * Check if a box passes local conditions | |
| 543 | + * Check if a box passes local assignments | |
| 575 | 544 | * |
| 576 | 545 | * @return boolean |
| 577 | 546 | */ |
| 578 | 547 | private function passLocalAssignments() |
| @@ -606,9 +575,9 @@ | ||
| 606 | 575 | |
| 607 | 576 | $box = $box[0]; |
| 608 | 577 | |
| 609 | 578 | // get meta options for box |
| 610 | - $meta = BoxHelper::getMeta($box->ID); | |
| 579 | + $meta = get_post_meta($box_id, 'fpframework_meta_settings', true); | |
| 611 | 580 | $box->params = new Registry($meta); |
| 612 | 581 | |
| 613 | 582 | return new Registry(['rules' => $box->params->get('rules')]); |
| 614 | 583 | } |
| @@ -649,9 +618,9 @@ | ||
| 649 | 618 | { |
| 650 | 619 | $box = $this->get($box_id); |
| 651 | 620 | |
| 652 | 621 | // Do not track if statistics option is disabled |
| 653 | - $track_open_event = (bool) (is_null($box->params->get('stats', null)) ? true : $box->params->get('stats')); | |
| 622 | + $track_open_event = (bool) (is_null($box->params->get('stats', null)) ? BoxHelper::getParams()->get('stats', 1) : $box->params->get('stats')); | |
| 654 | 623 | if (!$track_open_event) |
| 655 | 624 | { |
| 656 | 625 | return; |
| 657 | 626 | } |
| @@ -671,9 +640,9 @@ | ||
| 671 | 640 | { |
| 672 | 641 | $box = $this->get($box_id); |
| 673 | 642 | |
| 674 | 643 | // Do not track if statistics option is disabled |
| 675 | - $track_open_event = (bool) (is_null($box->params->get('stats', null)) ? true : $box->params->get('stats')); | |
| 644 | + $track_open_event = (bool) (is_null($box->params->get('stats', null)) ? BoxHelper::getParams()->get('stats', 1) : $box->params->get('stats')); | |
| 676 | 645 | if (!$track_open_event) |
| 677 | 646 | { |
| 678 | 647 | return null; |
| 679 | 648 | } |
| @@ -706,9 +675,9 @@ | ||
| 706 | 675 | { |
| 707 | 676 | return; |
| 708 | 677 | } |
| 709 | 678 | |
| 710 | - return new Cookie($this->box); | |
| 679 | + return new Cookie($this->box->id); | |
| 711 | 680 | } |
| 712 | 681 | |
| 713 | 682 | /** |
| 714 | 683 | * Returns the box. |
| @@ -732,32 +701,5 @@ | ||
| 732 | 701 | $this->box = $box; |
| 733 | 702 | |
| 734 | 703 | return $this; |
| 735 | 704 | } |
| 736 | - | |
| 737 | - public function getParams() | |
| 738 | - { | |
| 739 | - return $this->params; | |
| 740 | - } | |
| 741 | - | |
| 742 | - public function setParams($params) | |
| 743 | - { | |
| 744 | - $this->params = $params; | |
| 745 | - | |
| 746 | - return $this; | |
| 747 | - } | |
| 748 | - | |
| 749 | - public function getCampaignParams() | |
| 750 | - { | |
| 751 | - return isset($this->box->params) ? $this->box->params : null; | |
| 752 | - } | |
| 753 | - | |
| 754 | - public function setCampaignParams($params) | |
| 755 | - { | |
| 756 | - if (isset($this->box->params)) | |
| 757 | - { | |
| 758 | - $this->box->params = $params; | |
| 759 | - } | |
| 760 | - | |
| 761 | - return $this; | |
| 762 | - } | |
| 763 | -} | |
| 705 | +} | |