Changeset 4212 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php
- Timestamp:
- 10/11/2016 06:27:26 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php
r3511 r4212 24 24 switch( $cap ) { 25 25 26 // TODO: Map these for the users 26 27 case 'plugin_edit': 27 28 case 'plugin_add_committer': … … 29 30 $required_caps = array(); 30 31 $post = get_post( $context[0] ); 31 if ( ! $post instanceof \WP_Post) {32 if ( ! $post ) { 32 33 $required_caps[] = 'do_not_allow'; 33 34 break; … … 81 82 */ 82 83 public static function add_roles() { 83 $committer = array( 84 'read' => true, 85 'plugin_dashboard_access' => true, 86 'plugin_edit_own' => true, 87 'plugin_set_category' => true, 88 'plugin_add_committer' => true, 89 'plugin_edit_others' => true, 84 85 $reviewer = array( 86 'read' => true, 87 'plugin_edit_own' => true, 88 'plugin_set_category' => true, 89 'plugin_add_committer' => true, 90 'plugin_edit_others' => true, 91 'moderate_comments' => true, 92 'plugin_edit_pending' => true, 93 'plugin_review' => true, 90 94 ); 91 92 $reviewer = array_merge( $committer, array(93 'moderate_comments' => true,94 'plugin_edit_pending' => true,95 'plugin_review' => true,96 ) );97 95 98 96 $admin = array_merge( $reviewer, array( … … 106 104 107 105 // Remove the roles first, incase we've changed the permission set. 108 remove_role( 'plugin_committer' ); 109 remove_role( 'plugin_reviewer' ); 110 remove_role( 'plugin_admin' ); 111 add_role( 'plugin_committer', 'Plugin Committer', $committer ); 112 add_role( 'plugin_reviewer', 'Plugin Reviewer', $reviewer ); 113 add_role( 'plugin_admin', 'Plugin Admin', $admin ); 106 remove_role( 'plugin_reviewer' ); 107 remove_role( 'plugin_admin' ); 108 add_role( 'plugin_reviewer', 'Plugin Reviewer', $reviewer ); 109 add_role( 'plugin_admin', 'Plugin Admin', $admin ); 114 110 115 foreach ( array( 'contributor', 'author', 'editor', 'administrator' ) as $role ) { 116 $wp_role = get_role( $role ); 117 118 if ( ! $wp_role ) { 119 continue; 120 } 121 122 foreach ( $committer as $committer_cap => $value ) { 123 $wp_role->add_cap( $committer_cap ); 124 } 125 126 if ( in_array( $role, array( 'editor', 'administrator' ) ) ) { 127 foreach ( $admin as $admin_cap => $value ) { 128 $wp_role->add_cap( $admin_cap ); 129 } 111 $wp_admin_role = get_role( 'administrator' ); 112 if ( $wp_admin_role ) { 113 foreach ( $admin as $admin_cap => $value ) { 114 $wp_admin_role->add_cap( $admin_cap ); 130 115 } 131 116 } 132 117 133 update_option( 'default_role', ' plugin_committer' );118 update_option( 'default_role', 'subscriber' ); 134 119 } 135 120 }
Note: See TracChangeset
for help on using the changeset viewer.