@@ 117-170 (lines=54) @@ | ||
114 | * |
|
115 | * @return void |
|
116 | */ |
|
117 | public function add_caps() { |
|
118 | global $wp_roles; |
|
119 | ||
120 | if ( class_exists( 'WP_Roles' ) ) { |
|
121 | if ( ! isset( $wp_roles ) ) { |
|
122 | $wp_roles = new WP_Roles(); |
|
123 | } |
|
124 | } |
|
125 | ||
126 | if ( is_object( $wp_roles ) ) { |
|
127 | $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
128 | $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
129 | $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
130 | $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
131 | $wp_roles->add_cap( 'give_manager', 'view_give_payments' ); |
|
132 | ||
133 | $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
134 | $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
135 | $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
136 | $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
137 | $wp_roles->add_cap( 'administrator', 'view_give_payments' ); |
|
138 | ||
139 | // Add the main post type capabilities. |
|
140 | $capabilities = $this->get_core_caps(); |
|
141 | foreach ( $capabilities as $cap_group ) { |
|
142 | foreach ( $cap_group as $cap ) { |
|
143 | $wp_roles->add_cap( 'administrator', $cap ); |
|
144 | $wp_roles->add_cap( 'give_manager', $cap ); |
|
145 | } |
|
146 | } |
|
147 | ||
148 | // Add Capabilities to Give Workers User Role. |
|
149 | $wp_roles->add_cap( 'give_worker', 'edit_give_payments' ); |
|
150 | $wp_roles->add_cap( 'give_worker', 'delete_give_forms' ); |
|
151 | $wp_roles->add_cap( 'give_worker', 'delete_others_give_forms' ); |
|
152 | $wp_roles->add_cap( 'give_worker', 'delete_private_give_forms' ); |
|
153 | $wp_roles->add_cap( 'give_worker', 'delete_published_give_forms' ); |
|
154 | $wp_roles->add_cap( 'give_worker', 'edit_give_forms' ); |
|
155 | $wp_roles->add_cap( 'give_worker', 'edit_others_give_forms' ); |
|
156 | $wp_roles->add_cap( 'give_worker', 'edit_private_give_forms' ); |
|
157 | $wp_roles->add_cap( 'give_worker', 'edit_published_give_forms' ); |
|
158 | $wp_roles->add_cap( 'give_worker', 'publish_give_forms' ); |
|
159 | $wp_roles->add_cap( 'give_worker', 'read_private_give_forms' ); |
|
160 | ||
161 | // Add Capabilities to Give Accountant User Role. |
|
162 | $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
163 | $wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' ); |
|
164 | $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
165 | $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
166 | $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
167 | $wp_roles->add_cap( 'give_accountant', 'view_give_payments' ); |
|
168 | ||
169 | } |
|
170 | } |
|
171 | ||
172 | /** |
|
173 | * Get Core Capabilities |
|
@@ 272-329 (lines=58) @@ | ||
269 | * |
|
270 | * @return void |
|
271 | */ |
|
272 | public function remove_caps() { |
|
273 | ||
274 | global $wp_roles; |
|
275 | ||
276 | if ( class_exists( 'WP_Roles' ) ) { |
|
277 | if ( ! isset( $wp_roles ) ) { |
|
278 | $wp_roles = new WP_Roles(); |
|
279 | } |
|
280 | } |
|
281 | ||
282 | if ( is_object( $wp_roles ) ) { |
|
283 | // Give Manager Capabilities. |
|
284 | $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
285 | $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
286 | $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
287 | $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
288 | ||
289 | // Site Administrator Capabilities. |
|
290 | $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
291 | $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
292 | $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
293 | $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
294 | $wp_roles->remove_cap( 'administrator', 'view_give_payments' ); |
|
295 | ||
296 | // Remove the Main Post Type Capabilities. |
|
297 | $capabilities = $this->get_core_caps(); |
|
298 | ||
299 | foreach ( $capabilities as $cap_group ) { |
|
300 | foreach ( $cap_group as $cap ) { |
|
301 | $wp_roles->remove_cap( 'give_manager', $cap ); |
|
302 | $wp_roles->remove_cap( 'administrator', $cap ); |
|
303 | ||
304 | } |
|
305 | } |
|
306 | ||
307 | // Remove capabilities from the Give Worker role. |
|
308 | $wp_roles->remove_cap( 'give_worker', 'edit_give_payments' ); |
|
309 | $wp_roles->remove_cap( 'give_worker', 'delete_give_forms' ); |
|
310 | $wp_roles->remove_cap( 'give_worker', 'delete_others_give_forms' ); |
|
311 | $wp_roles->remove_cap( 'give_worker', 'delete_private_give_forms' ); |
|
312 | $wp_roles->remove_cap( 'give_worker', 'delete_published_give_forms' ); |
|
313 | $wp_roles->remove_cap( 'give_worker', 'edit_give_forms' ); |
|
314 | $wp_roles->remove_cap( 'give_worker', 'edit_others_give_forms' ); |
|
315 | $wp_roles->remove_cap( 'give_worker', 'edit_private_give_forms' ); |
|
316 | $wp_roles->remove_cap( 'give_worker', 'edit_published_give_forms' ); |
|
317 | $wp_roles->remove_cap( 'give_worker', 'publish_give_forms' ); |
|
318 | $wp_roles->remove_cap( 'give_worker', 'read_private_give_forms' ); |
|
319 | ||
320 | // Remove Capabilities from Give Accountant User Role. |
|
321 | $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
322 | $wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' ); |
|
323 | $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
324 | $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
325 | $wp_roles->remove_cap( 'give_accountant', 'edit_give_payments' ); |
|
326 | $wp_roles->remove_cap( 'give_accountant', 'view_give_payments' ); |
|
327 | ||
328 | } |
|
329 | } |
|
330 | ||
331 | /** |
|
332 | * Allow admin dashboard to User with Give Accountant Role. |