PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.4
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.4
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/Admin/Capabilities.php +94 -42 3.1.72.1.4 View file →
@@ -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\Admin;
@@ -22,61 +22,113 @@
22 22 {
23 23 $this->setup();
24 24 }
25 25
26 - public static function getCapabilities()
26 + private function setup()
27 27 {
28 - return [
29 - 'edit_firebox',
30 - 'read_firebox',
31 - 'delete_firebox',
32 - 'edit_fireboxes',
33 - 'edit_others_fireboxes',
34 - 'publish_fireboxes',
35 - 'read_private_fireboxes',
36 - 'read_fireboxes',
37 - 'delete_fireboxes',
38 - 'delete_private_fireboxes',
39 - 'delete_published_fireboxes',
40 - 'delete_others_fireboxes',
41 - 'edit_private_fireboxes',
42 - 'edit_published_fireboxes'
28 + global $wp_roles;
29 +
30 + if ( ! class_exists( 'WP_Roles' ) ) {
31 + return;
32 + }
33 +
34 + if ( ! isset( $wp_roles ) ) {
35 + $wp_roles = new WP_Roles();
36 + }
37 +
38 + $capabilities = [];
39 +
40 + // get all CPTs
41 + $cpts = [
42 + 'firebox' => [
43 + 'singular' => 'firebox',
44 + 'plural' => 'fireboxes'
45 + ]
43 46 ];
44 - }
45 47
46 - private function setup()
47 - {
48 - $capabilities = self::getCapabilities();
48 + foreach ($cpts as $name => $data)
49 + {
50 + $singular = $data['singular'];
51 + $plural = $data['plural'];
49 52
50 - $admin = get_role('administrator');
53 + $capabilities[strtolower($name)] = [
54 + 'edit_post' => "edit_$singular",
55 + 'read_post' => "read_$singular",
56 + 'delete_post' => "delete_$singular",
57 + 'edit_posts' => "edit_$plural",
58 + 'edit_others_posts' => "edit_others_$plural",
59 + 'publish_posts' => "publish_$plural",
60 + 'read_private_posts' => "read_private_$plural",
61 + 'read' => "read_$singular",
62 + 'delete_posts' => "delete_$plural",
63 + 'delete_private_posts' => "delete_private_$plural",
64 + 'delete_published_posts' => "delete_published_$plural",
65 + 'delete_others_posts' => "delete_others_$plural",
66 + 'edit_private_posts' => "edit_private_$plural",
67 + 'edit_published_posts' => "edit_published_$plural",
68 + 'create_posts' => "edit_$plural",
69 + ];
51 70
52 - if ($admin)
53 - {
54 - foreach ($capabilities as $cap)
71 + // also add taxonomies
72 + if (isset($data['taxonomies']) && is_array($data['taxonomies']) && count($data['taxonomies']))
55 73 {
56 - $admin->add_cap($cap);
74 + foreach ($data['taxonomies'] as $tax)
75 + {
76 + $tmp_tax = $name . '_' . $tax;
77 +
78 + $capabilities[strtolower($name)]["manage_{$name}_{$tmp_tax}_terms"] = "manage_{$name}_{$tmp_tax}_terms";
79 + $capabilities[strtolower($name)]["edit_{$name}_{$tmp_tax}_terms"] = "edit_{$name}_{$tmp_tax}_terms";
80 + $capabilities[strtolower($name)]["assign_{$name}_{$tmp_tax}_terms"] = "assign_{$name}_{$tmp_tax}_terms";
81 + $capabilities[strtolower($name)]["delete_{$name}_{$tmp_tax}_terms"] = "delete_{$name}_{$tmp_tax}_terms";
82 + }
57 83 }
58 84 }
59 - else
60 - {
61 - $roles = get_editable_roles();
62 85
63 - foreach ($roles as $role_name => $data)
64 - {
65 - if (isset($data['capabilities']['manage_options']) && $data['capabilities']['manage_options'])
66 - {
67 - $role = get_role($role_name);
86 + //Set capabilities to all roles with cap:"".
87 + $roles = $wp_roles->get_names();
68 88
69 - foreach ($capabilities as $cap)
70 - {
71 - if ($role)
72 - {
73 - $role->add_cap($cap);
89 + // add capabilities to all roles
90 + foreach ( $capabilities as $name => $capabilities) {
91 + $capabilities_data = array_values($capabilities);
92 +
93 + // all roles
94 + foreach ( $roles as $current_role => $role_name ) {
95 + if ( isset( $wp_roles->roles[ $current_role ][ 'capabilities' ][ 'manage_options' ] ) ) {
96 + $role = get_role( $current_role );
97 + if ( isset( $role ) && is_object( $role ) ) {
98 + for ( $i = 0, $caps_limit = count( $capabilities_data ); $i < $caps_limit; $i ++ ) {
99 + if ( ! isset( $wp_roles->roles[ $current_role ][ 'capabilities' ][ $capabilities_data[ $i ] ] ) ) {
100 + $role->add_cap( $capabilities_data[ $i ] );
101 + }
74 102 }
75 103 }
104 +
76 105 }
77 106 }
107 +
108 + // all admins
109 + $user_admins = get_users( array(
110 + 'role' => 'administrator'
111 + ) );
112 +
113 + if ( is_multisite() ) {
114 + $super_admins = get_super_admins();
115 +
116 + foreach( $super_admins as $admin ) {
117 + $super_admin = new \WP_User( $admin );
118 +
119 + if ( ! in_array( $super_admin, $user_admins, true ) ) {
120 + $user_admins[] = $super_admin;
121 + }
122 + }
123 + }
124 +
125 + foreach ( $user_admins as $user ) {
126 + if ( $user->exists() ) {
127 + for ( $i = 0, $caps_limit = count( $capabilities_data ); $i < $caps_limit; $i ++ ) {
128 + $user->add_cap( $capabilities_data[ $i ] );
129 + }
130 + }
131 + }
78 132 }
79 -
80 - wp_get_current_user()->get_role_caps();
81 133 }
82 134 }