PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 2.1
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v2.1
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
features 5 years ago roles 5 years ago admin.php 5 years ago backup-handler.php 5 years ago backup.php 5 years ago cap-helper.php 6 years ago filters-admin.php 6 years ago filters-woocommerce.php 7 years ago filters-wp_rest_workarounds.php 5 years ago filters.php 5 years ago functions-admin.php 5 years ago functions.php 5 years ago handler.php 5 years ago inflect-cme.php 7 years ago manager.php 5 years ago network.php 5 years ago pp-handler.php 6 years ago pp-ui.php 5 years ago publishpress-roles.php 5 years ago settings-handler.php 5 years ago settings.php 5 years ago
network.php
79 lines
1 <?php
2 add_action( 'wpmu_new_blog', '_cme_new_blog' );
3 function _cme_new_blog( $new_blog_id ) {
4 if ( $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) ) {
5 global $wp_roles, $blog_id;
6
7 $restore_blog_id = $blog_id;
8
9 $main_site_id = (function_exists('get_main_site_id')) ? get_main_site_id() : 1;
10
11 switch_to_blog($main_site_id);
12 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
13
14 $main_site_caps = array();
15 $role_captions = array();
16
17 $admin_role = $wp_roles->get_role('administrator');
18 $main_admin_caps = $admin_role->capabilities;
19
20 if ( defined('PRESSPERMIT_ACTIVE') )
21 $main_pp_only = (array) pp_capabilities_get_permissions_option( 'supplemental_role_defs' );
22 //$pp_only[]= $newrole;
23
24 foreach( $autocreate_roles as $role_name ) {
25 if ( $role = get_role( $role_name ) ) {
26 $main_site_caps[$role_name] = $role->capabilities;
27 $role_captions[$role_name] = $wp_roles->role_names[$role_name];
28 }
29 }
30
31 switch_to_blog($new_blog_id);
32 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
33
34 if ( defined('PRESSPERMIT_ACTIVE') ) {
35 pp_refresh_options();
36 $blog_pp_only = (array) pp_capabilities_get_permissions_option( 'supplemental_role_defs' );
37 }
38
39 foreach( $main_site_caps as $role_name => $caps ) {
40 if ( $blog_role = $wp_roles->get_role( $role_name ) ) {
41 $stored_role_caps = ( ! empty($blog_role->capabilities) && is_array($blog_role->capabilities) ) ? array_intersect( $blog_role->capabilities, array(true, 1) ) : array();
42
43 // Find caps to add and remove
44 $add_caps = array_diff_key($caps, $stored_role_caps);
45 $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
46
47 // Add new capabilities to role
48 foreach ( $add_caps as $cap => $grant )
49 $blog_role->add_cap($cap);
50
51 // Remove capabilities from role
52 foreach ( $del_caps as $cap => $grant)
53 $blog_role->remove_cap($cap);
54 } else {
55 $wp_roles->add_role( $role_name, $role_captions[$role_name], $caps );
56 }
57
58 if ( defined('PRESSPERMIT_ACTIVE') ) {
59 if ( in_array( $role_name, $main_pp_only ) ) {
60 _cme_pp_default_pattern_role( $role_name );
61 $blog_pp_only []= $role_name;
62 } else
63 array_diff( $blog_pp_only, array( $role_name ) );
64 }
65 }
66
67 if ( defined('PRESSPERMIT_ACTIVE') ) {
68 pp_capabilities_update_permissions_option('supplemental_role_defs', $blog_pp_only);
69 }
70
71 restore_current_blog();
72 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
73
74 if ( defined('PRESSPERMIT_ACTIVE') )
75 pp_refresh_options();
76 }
77 }
78
79