PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.39
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.39
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 +43 -94 1.0.62.1.39 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 1.0.6 Free
4 + * @version 2.1.39 Free
5 5 *
6 6 * @author FirePlugins <info@fireplugins.com>
7 7 * @link https://www.fireplugins.com
8 - * @copyright Copyright © 2021 FirePlugins All Rights Reserved
8 + * @copyright Copyright © 2025 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,113 +22,62 @@
22 22 {
23 23 $this->setup();
24 24 }
25 25
26 + public static function getCapabilities()
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',
43 + 'edit_fireboxes'
44 + ];
45 + }
46 +
26 47 private function setup()
27 48 {
28 - global $wp_roles;
49 + $capabilities = self::getCapabilities();
29 50
30 - if ( ! class_exists( 'WP_Roles' ) ) {
31 - return;
32 - }
51 + $admin = get_role('administrator');
33 52
34 - if ( ! isset( $wp_roles ) ) {
35 - $wp_roles = new WP_Roles();
53 + if ($admin)
54 + {
55 + foreach ($capabilities as $cap)
56 + {
57 + $admin->add_cap($cap);
58 + }
36 59 }
37 -
38 - $capabilities = [];
39 -
40 - // get all CPTs
41 - $cpts = [
42 - 'firebox' => [
43 - 'singular' => 'firebox',
44 - 'plural' => 'fireboxes'
45 - ]
46 - ];
47 -
48 - foreach ($cpts as $name => $data)
60 + else
49 61 {
50 - $singular = $data['singular'];
51 - $plural = $data['plural'];
62 + $roles = get_editable_roles();
52 63
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 - ];
70 -
71 - // also add taxonomies
72 - if (isset($data['taxonomies']) && is_array($data['taxonomies']) && count($data['taxonomies']))
64 + foreach ($roles as $role_name => $data)
73 65 {
74 - foreach ($data['taxonomies'] as $tax)
66 + if (isset($data['capabilities']['manage_options']) && $data['capabilities']['manage_options'])
75 67 {
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 - }
83 - }
84 - }
68 + $role = get_role($role_name);
85 69
86 - //Set capabilities to all roles with cap:"".
87 - $roles = $wp_roles->get_names();
88 -
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 - }
70 + foreach ($capabilities as $cap)
71 + {
72 + if ($role)
73 + {
74 + $role->add_cap($cap);
102 75 }
103 76 }
104 -
105 77 }
106 78 }
79 + }
107 80
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 - }
132 - }
81 + wp_get_current_user()->get_role_caps();
133 82 }
134 83 }