PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 2.19.0
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v2.19.0
2.45.0 2.44.0 trunk 1.10 1.10.1 1.4.1 1.4.10 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.7 1.5.8 1.5.9 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.8.1 1.9 1.9.10 1.9.12 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.9 2.0 2.0.2 2.0.3 2.1 2.1.1 2.10.0 2.10.1 2.10.2 2.10.3 2.11.1 2.12.1 2.12.2 2.13.0 2.14.0 2.15.0 2.16.0 2.17.0 2.18.0 2.18.2 2.19.0 2.19.1 2.19.2 2.2 2.2.1 2.20.0 2.21.0 2.22.0 2.23.0 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.30.0 2.31.0 2.32.0 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.40.0 2.41.0 2.42.0 2.43.0 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.7.0 2.7.1 2.8.0 2.8.1 2.9.0 2.9.1
capability-manager-enhanced / includes / network.php
capability-manager-enhanced / includes Last commit date
admin-notices 1 year ago features 1 year ago plugin-capabilities 1 year ago redirects 1 year ago roles 1 year ago admin-load.php 1 year ago admin.php 1 year ago backup-handler.php 1 year ago backup.php 1 year ago cap-helper.php 1 year ago dashboard.php 1 year ago extractor-capabilities.php 1 year ago filters-admin.php 1 year ago filters-woocommerce.php 1 year ago filters-wp_rest_workarounds.php 1 year ago filters.php 1 year ago functions-admin.php 1 year ago functions.php 1 year ago handler.php 1 year ago inflect-cme.php 1 year ago manager.php 1 year ago network.php 1 year ago plugin-capabilities.php 1 year ago pp-handler.php 1 year ago pp-ui.php 1 year ago publishpress-roles.php 1 year ago settings-handler.php 1 year ago settings-ui.php 1 year ago settings.php 1 year ago test-user-ui.php 1 year ago test-user.php 1 year ago
network.php
86 lines
1 <?php
2 /*
3 * PublishPress Capabilities [Free]
4 *
5 * Multisite-related functions / filter handlers
6 *
7 */
8
9 add_action( 'wpmu_new_blog', '_cme_new_blog' );
10 function _cme_new_blog( $new_blog_id ) {
11 if ( $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) ) {
12 global $wp_roles, $blog_id;
13
14 $restore_blog_id = $blog_id;
15
16 $main_site_id = (function_exists('get_main_site_id')) ? get_main_site_id() : 1;
17
18 switch_to_blog($main_site_id);
19 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
20
21 $main_site_caps = array();
22 $role_captions = array();
23
24 $admin_role = $wp_roles->get_role('administrator');
25 $main_admin_caps = $admin_role->capabilities;
26
27 if ( defined('PRESSPERMIT_ACTIVE') ) {
28 $main_pp_only = (array) pp_capabilities_get_permissions_option( 'supplemental_role_defs' );
29 }
30
31 foreach( $autocreate_roles as $role_name ) {
32 if ( $role = get_role( $role_name ) ) {
33 $main_site_caps[$role_name] = $role->capabilities;
34 $role_captions[$role_name] = $wp_roles->role_names[$role_name];
35 }
36 }
37
38 switch_to_blog($new_blog_id);
39 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
40
41 if ( defined('PRESSPERMIT_ACTIVE') ) {
42 pp_refresh_options();
43 $blog_pp_only = (array) pp_capabilities_get_permissions_option( 'supplemental_role_defs' );
44 }
45
46 foreach( $main_site_caps as $role_name => $caps ) {
47 if ( $blog_role = $wp_roles->get_role( $role_name ) ) {
48 $stored_role_caps = ( ! empty($blog_role->capabilities) && is_array($blog_role->capabilities) ) ? array_intersect( $blog_role->capabilities, array(true, 1) ) : array();
49
50 // Find caps to add and remove
51 $add_caps = array_diff_key($caps, $stored_role_caps);
52 $del_caps = array_intersect_key( array_diff_key($stored_role_caps, $caps), $main_admin_caps ); // don't mess with caps that are totally unused on main site
53
54 // Add new capabilities to role
55 foreach ( $add_caps as $cap => $grant )
56 $blog_role->add_cap($cap);
57
58 // Remove capabilities from role
59 foreach ( $del_caps as $cap => $grant)
60 $blog_role->remove_cap($cap);
61 } else {
62 $wp_roles->add_role( $role_name, $role_captions[$role_name], $caps );
63 }
64
65 if ( defined('PRESSPERMIT_ACTIVE') ) {
66 if ( in_array( $role_name, $main_pp_only ) ) {
67 _cme_pp_default_pattern_role( $role_name );
68 $blog_pp_only []= $role_name;
69 } else
70 array_diff( $blog_pp_only, array( $role_name ) );
71 }
72 }
73
74 if ( defined('PRESSPERMIT_ACTIVE') ) {
75 pp_capabilities_update_permissions_option('supplemental_role_defs', $blog_pp_only);
76 }
77
78 restore_current_blog();
79 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
80
81 if ( defined('PRESSPERMIT_ACTIVE') )
82 pp_refresh_options();
83 }
84 }
85
86