PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.14
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
← All changes | Inc/Core/Migrator.php +5 -280 trunk2.1.14 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 3.1.13 Free
4 + * @version 2.1.14 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;
@@ -52,16 +52,8 @@
52 52 $this->updatePublishingRulesToConditionBuilder();
53 53 $this->updateEcommerceProductsInCartConditions();
54 54 $this->updateAnalyticsStoragePeriodSetting();
55 55 $this->update213version();
56 - $this->addMissingCapabilities();
57 -
58 -
59 - $this->addNewIndexes();
60 - $this->addSubmissionsIndexes();
61 - $this->preserveCampaignRoleAccess();
62 - $this->grantExecutePHPCapability();
63 - $this->grantExecuteJSCapability();
64 56
65 57 // Update firebox version
66 58 if ($this->run)
67 59 {
@@ -308,9 +300,9 @@
308 300 {
309 301 return;
310 302 }
311 303
312 - $params = get_option('firebox_settings', []);
304 + $params = get_option('firebox_settings');
313 305
314 306 $statsdays = isset($params['statsdays']) ? $params['statsdays'] : 730;
315 307 $statsdays_custom = isset($params['statsdays_custom']) ? $params['statsdays_custom'] : false;
316 308
@@ -406,9 +398,9 @@
406 398 "{$wpdb->prefix}firebox_submission_meta.meta_value",
407 399 "{$wpdb->prefix}firebox_submission_meta.created_at"
408 400 ],
409 401 'where' => [
410 - 'meta_key' => " = '" . absint('box_log_id') . "'"
402 + 'meta_key' => " = '" . esc_sql('box_log_id') . "'"
411 403 ],
412 404 'join' => [
413 405 "LEFT JOIN" => " {$wpdb->prefix}firebox_submissions as s ON s.id = submission_id LEFT JOIN {$wpdb->prefix}firebox_logs as l ON l.id = meta_value",
414 406 ]
@@ -450,106 +442,9 @@
450 442
451 443 $this->run = true;
452 444 }
453 445
454 - public function addMissingCapabilities()
455 - {
456 - if (version_compare($this->installedVersion, '2.1.15', '>='))
457 - {
458 - return;
459 - }
460 -
461 - $cap_name = 'read_fireboxes';
462 -
463 - $admin = get_role('administrator');
464 -
465 - if ($admin)
466 - {
467 - if ($admin->has_cap($cap_name))
468 - {
469 - return true;
470 - }
471 -
472 - $admin->add_cap($cap_name);
473 - }
474 - else
475 - {
476 - $roles = get_editable_roles();
477 -
478 - foreach ($roles as $role_name => $data)
479 - {
480 - if (isset($data['capabilities']['manage_options']) && $data['capabilities']['manage_options'])
481 - {
482 - $role = get_role($role_name);
483 -
484 - if (!$role)
485 - {
486 - continue;
487 - }
488 -
489 - if ($role->has_cap($cap_name))
490 - {
491 - continue;
492 - }
493 -
494 - $role->add_cap($cap_name);
495 - }
496 - }
497 - }
498 -
499 - wp_get_current_user()->get_role_caps();
500 -
501 - return true;
502 - }
503 -
504 -
505 -
506 -
507 -
508 446 /**
509 - * Adds new indexes to the logs details table.
510 - *
511 - * @since 3.1.0
512 - *
513 - * @return void
514 - */
515 - private function addNewIndexes()
516 - {
517 - if (version_compare($this->installedVersion, '3.1.0', '>='))
518 - {
519 - return;
520 - }
521 -
522 - if (!$this->hasIndex('idx_firebox_logs_details_event_log', 'firebox_logs_details'))
523 - {
524 - global $wpdb;
525 - $wpdb->query("ALTER TABLE {$wpdb->prefix}firebox_logs_details ADD INDEX `idx_firebox_logs_details_event_log` (`event`, `log_id`)");
526 - }
527 - if (!$this->hasIndex('idx_firebox_logs_details_event_source_log', 'firebox_logs_details'))
528 - {
529 - global $wpdb;
530 - $wpdb->query("ALTER TABLE {$wpdb->prefix}firebox_logs_details ADD INDEX `idx_firebox_logs_details_event_source_log` (`event_source`, `log_id`)");
531 - }
532 - if (!$this->hasIndex('idx_firebox_logs_details_event_date', 'firebox_logs_details'))
533 - {
534 - global $wpdb;
535 - $wpdb->query("ALTER TABLE {$wpdb->prefix}firebox_logs_details ADD INDEX `idx_firebox_logs_details_event_date` (`event`, `date`)");
536 - }
537 - if (!$this->hasIndex('idx_firebox_logs_details_event_source_event_log', 'firebox_logs_details'))
538 - {
539 - global $wpdb;
540 - $wpdb->query("ALTER TABLE {$wpdb->prefix}firebox_logs_details ADD INDEX `idx_firebox_logs_details_event_source_event_log` (`event_source`, `event`, `log_id`)");
541 - }
542 - if (!$this->hasIndex('idx_firebox_logs_details_event_source_event_date', 'firebox_logs_details'))
543 - {
544 - global $wpdb;
545 - $wpdb->query("ALTER TABLE {$wpdb->prefix}firebox_logs_details ADD INDEX `idx_firebox_logs_details_event_source_event_date` (`event_source`, `event`, `date`)");
546 - }
547 -
548 - $this->run = true;
549 - }
550 -
551 - /**
552 447 * Checks whether an index exists in a table.
553 448 *
554 449 * @param string $index
555 450 * @param string $table
@@ -555,178 +450,8 @@
555 450 * @param string $table
556 451 *
557 452 * @return bool
558 453 */
559 - /**
560 - * Adds missing indexes on the submissions tables to speed up
561 - * form_id/state lookups and submission_id meta lookups.
562 - *
563 - * @since 3.1.9
564 - *
565 - * @return void
566 - */
567 - private function addSubmissionsIndexes()
568 - {
569 - if (version_compare($this->installedVersion, '3.1.9', '>='))
570 - {
571 - return;
572 - }
573 -
574 - if (!$this->hasIndex('idx_form_id_state', 'firebox_submissions'))
575 - {
576 - global $wpdb;
577 - $wpdb->query("ALTER TABLE {$wpdb->prefix}firebox_submissions ADD INDEX `idx_form_id_state` (`form_id`, `state`)");
578 - }
579 -
580 - if (!$this->hasIndex('idx_submission_id', 'firebox_submission_meta'))
581 - {
582 - global $wpdb;
583 - $wpdb->query("ALTER TABLE {$wpdb->prefix}firebox_submission_meta ADD INDEX `idx_submission_id` (`submission_id`)");
584 - }
585 -
586 - $this->run = true;
587 - }
588 -
589 - /**
590 - * Keeps existing roles' campaign access working after the campaign post type moved
591 - * from core's "post" capabilities to FireBox's own.
592 - *
593 - * Before this change anyone with edit_posts could edit campaigns. Granting each role
594 - * the FireBox capability matching the core capability it already holds preserves
595 - * exactly who could do what, so upgrading changes nobody's access.
596 - *
597 - * Note this deliberately does not grant read_fireboxes: that gates the FireBox admin
598 - * screens, was never derived from the post type, and granting it here would hand
599 - * roles access they did not previously have.
600 - *
601 - * Site owners who want to tighten campaign access can now remove these capabilities
602 - * and have it actually take effect, which was not previously the case.
603 - *
604 - * @since 3.1.10
605 - *
606 - * @return void
607 - */
608 - private function preserveCampaignRoleAccess()
609 - {
610 - if (version_compare($this->installedVersion, '3.1.10', '>='))
611 - {
612 - return;
613 - }
614 -
615 - $map = \FireBox\Core\Admin\Includes\Cpts\Firebox::getPostTypeCapabilities();
616 -
617 - // Only the primitive capabilities are assigned to roles.
618 - unset($map['edit_post'], $map['read_post'], $map['delete_post'], $map['create_posts']);
619 -
620 - // wp_roles() rather than get_editable_roles(): the latter is admin-only and
621 - // undefined on the frontend requests this migration also runs on.
622 - foreach (wp_roles()->role_objects as $role)
623 - {
624 - foreach ($map as $core_cap => $firebox_cap)
625 - {
626 - if (!empty($role->capabilities[$core_cap]))
627 - {
628 - $role->add_cap($firebox_cap);
629 - }
630 - }
631 - }
632 -
633 - $this->run = true;
634 - }
635 -
636 - /**
637 - * Grants the firebox_execute_php capability to administrators.
638 - *
639 - * This capability gates the PHP display condition and PHP Scripts. It is separate
640 - * from the campaign-editing capabilities on purpose, so editing a campaign never
641 - * grants the ability to run PHP. Existing installs get it on administrators here;
642 - * a site owner can grant it to another role deliberately.
643 - *
644 - * @since 3.1.11
645 - *
646 - * @return void
647 - */
648 - private function grantExecutePHPCapability()
649 - {
650 - if (version_compare($this->installedVersion, '3.1.11', '>='))
651 - {
652 - return;
653 - }
654 -
655 - $cap = 'firebox_execute_php';
656 -
657 - $admin = get_role('administrator');
658 -
659 - if ($admin)
660 - {
661 - if (!$admin->has_cap($cap))
662 - {
663 - $admin->add_cap($cap);
664 - $this->run = true;
665 - }
666 -
667 - return;
668 - }
669 -
670 - // No administrator role on this install: fall back to roles that manage options.
671 - foreach (wp_roles()->role_objects as $role)
672 - {
673 - if (!empty($role->capabilities['manage_options']) && !$role->has_cap($cap))
674 - {
675 - $role->add_cap($cap);
676 - $this->run = true;
677 - }
678 - }
679 - }
680 -
681 - /**
682 - * Grants the firebox_execute_js capability to administrators.
683 - *
684 - * This capability gates campaign-authored JavaScript (the Custom JavaScript
685 - * setting and the "Run Javascript" action) alongside unfiltered_html. It exists
686 - * so administrators keep custom JS where WordPress withholds unfiltered_html
687 - * (multisite site admins, DISALLOW_UNFILTERED_HTML hosts). Like
688 - * firebox_execute_php it is separate from the campaign-editing capabilities on
689 - * purpose, so editing a campaign never grants it; a site owner can grant it to
690 - * another role deliberately.
691 - *
692 - * @since 3.1.11
693 - *
694 - * @return void
695 - */
696 - private function grantExecuteJSCapability()
697 - {
698 - if (version_compare($this->installedVersion, '3.1.11', '>='))
699 - {
700 - return;
701 - }
702 -
703 - $cap = 'firebox_execute_js';
704 -
705 - $admin = get_role('administrator');
706 -
707 - if ($admin)
708 - {
709 - if (!$admin->has_cap($cap))
710 - {
711 - $admin->add_cap($cap);
712 - $this->run = true;
713 - }
714 -
715 - return;
716 - }
717 -
718 - // No administrator role on this install: fall back to roles that manage options.
719 - foreach (wp_roles()->role_objects as $role)
720 - {
721 - if (!empty($role->capabilities['manage_options']) && !$role->has_cap($cap))
722 - {
723 - $role->add_cap($cap);
724 - $this->run = true;
725 - }
726 - }
727 - }
728 -
729 454 private function hasIndex($index = '', $table = '')
730 455 {
731 456 if (empty($index) || empty($table))
732 457 {
@@ -743,5 +468,5 @@
743 468 }
744 469
745 470 return false;
746 471 }
747 -}
472 +}