| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.10 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | 8 | * @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| @@ -58,8 +58,10 @@ | ||
| 58 | 58 | |
| 59 | 59 | $this->addNewIndexes(); |
| 60 | 60 | $this->addSubmissionsIndexes(); |
| 61 | 61 | $this->preserveCampaignRoleAccess(); |
| 62 | + $this->grantExecutePHPCapability(); | |
| 63 | + $this->grantExecuteJSCapability(); | |
| 62 | 64 | |
| 63 | 65 | // Update firebox version |
| 64 | 66 | if ($this->run) |
| 65 | 67 | { |
| @@ -628,8 +630,101 @@ | ||
| 628 | 630 | } |
| 629 | 631 | } |
| 630 | 632 | |
| 631 | 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 | + } | |
| 632 | 727 | } |
| 633 | 728 | |
| 634 | 729 | private function hasIndex($index = '', $table = '') |
| 635 | 730 | { |