| @@ -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\Admin; |
| @@ -32,9 +32,9 @@ | ||
| 32 | 32 | 'edit_fireboxes', |
| 33 | 33 | 'edit_others_fireboxes', |
| 34 | 34 | 'publish_fireboxes', |
| 35 | 35 | 'read_private_fireboxes', |
| 36 | - 'read_fireboxes', | |
| 36 | + 'read_firebox', | |
| 37 | 37 | 'delete_fireboxes', |
| 38 | 38 | 'delete_private_fireboxes', |
| 39 | 39 | 'delete_published_fireboxes', |
| 40 | 40 | 'delete_others_fireboxes', |
| @@ -39,22 +39,9 @@ | ||
| 39 | 39 | 'delete_published_fireboxes', |
| 40 | 40 | 'delete_others_fireboxes', |
| 41 | 41 | 'edit_private_fireboxes', |
| 42 | 42 | 'edit_published_fireboxes', |
| 43 | - | |
| 44 | - // Standalone permission to run campaign-authored PHP (display condition and | |
| 45 | - // PHP Scripts). Deliberately NOT part of getPostTypeCapabilities(), so editing | |
| 46 | - // campaigns never grants it implicitly — only administrators get it by default, | |
| 47 | - // and a site owner can grant it to another role on purpose. | |
| 48 | - 'firebox_execute_php', | |
| 49 | - | |
| 50 | - // Standalone permission to emit campaign-authored JavaScript (the Custom | |
| 51 | - // JavaScript setting and the "Run Javascript" action). unfiltered_html also | |
| 52 | - // satisfies that gate; this capability exists so administrators keep custom JS | |
| 53 | - // where WordPress withholds unfiltered_html (multisite site admins, | |
| 54 | - // DISALLOW_UNFILTERED_HTML hosts), and so a site owner can grant it to a | |
| 55 | - // trusted role deliberately. Same rules as firebox_execute_php otherwise. | |
| 56 | - 'firebox_execute_js' | |
| 43 | + 'edit_fireboxes' | |
| 57 | 44 | ]; |
| 58 | 45 | } |
| 59 | 46 | |
| 60 | 47 | private function setup() |
| @@ -64,9 +51,12 @@ | ||
| 64 | 51 | $admin = get_role('administrator'); |
| 65 | 52 | |
| 66 | 53 | if ($admin) |
| 67 | 54 | { |
| 68 | - self::addCapabilities($admin, $capabilities); | |
| 55 | + foreach ($capabilities as $cap) | |
| 56 | + { | |
| 57 | + $admin->add_cap($cap); | |
| 58 | + } | |
| 69 | 59 | } |
| 70 | 60 | else |
| 71 | 61 | { |
| 72 | 62 | $roles = get_editable_roles(); |
| @@ -76,11 +66,14 @@ | ||
| 76 | 66 | if (isset($data['capabilities']['manage_options']) && $data['capabilities']['manage_options']) |
| 77 | 67 | { |
| 78 | 68 | $role = get_role($role_name); |
| 79 | 69 | |
| 80 | - if ($role) | |
| 70 | + foreach ($capabilities as $cap) | |
| 81 | 71 | { |
| 82 | - self::addCapabilities($role, $capabilities); | |
| 72 | + if ($role) | |
| 73 | + { | |
| 74 | + $role->add_cap($cap); | |
| 75 | + } | |
| 83 | 76 | } |
| 84 | 77 | } |
| 85 | 78 | } |
| 86 | 79 | } |
| @@ -85,30 +78,6 @@ | ||
| 85 | 78 | } |
| 86 | 79 | } |
| 87 | 80 | |
| 88 | 81 | wp_get_current_user()->get_role_caps(); |
| 89 | - } | |
| 90 | - | |
| 91 | - /** | |
| 92 | - * Adds the capabilities a role is missing. | |
| 93 | - * | |
| 94 | - * add_cap() writes the role option on every call, and this now runs on | |
| 95 | - * every site of a network, so only the missing ones are added. | |
| 96 | - * | |
| 97 | - * @param \WP_Role $role | |
| 98 | - * @param array $capabilities | |
| 99 | - * | |
| 100 | - * @return void | |
| 101 | - */ | |
| 102 | - private static function addCapabilities($role, $capabilities) | |
| 103 | - { | |
| 104 | - foreach ($capabilities as $cap) | |
| 105 | - { | |
| 106 | - if ($role->has_cap($cap)) | |
| 107 | - { | |
| 108 | - continue; | |
| 109 | - } | |
| 110 | - | |
| 111 | - $role->add_cap($cap); | |
| 112 | - } | |
| 113 | 82 | } |
| 114 | 83 | } |