Changeset 6182
- Timestamp:
- 11/27/2017 11:56:22 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-subroles.php
r5612 r6182 70 70 71 71 switch ( $subrole ) { 72 case 'jetpack_connector' : 73 $newcaps = array( 74 'manage_network' => true, // Access to network admin. 75 'jetpack_connect' => true, 76 'jetpack_reconnect' => true, 77 'jetpack_disconnect' => true, 78 'jetpack_network_admin_page' => true, 79 'jetpack_network_sites_page' => true, 80 'jetpack_manage_modules' => true, 81 ); 82 break; 83 72 /** 73 * Mentor Manager 74 * 75 * - Access and use the WordCamp Mentors Dashboard screen on Central. 76 * - Edit `wordcamp` posts on Central. 77 */ 84 78 case 'mentor_manager' : 85 79 // These capabilities only apply on central.wordcamp.org. 86 80 if ( BLOG_ID_CURRENT_SITE === get_current_blog_id() ) { 87 81 $newcaps = array( 88 'read' => true, // Access to wp-admin. 89 'edit_posts' => true, // Access to WCPT posts. 90 'edit_published_posts' => true, // Access to WCPT posts. 91 'wordcamp_manage_mentors' => true, 82 'read' => true, // Access to wp-admin. 83 'wordcamp_manage_mentors' => true, 84 'wordcamp_wrangle_wordcamps' => true, 85 ); 86 } 87 break; 88 89 /** 90 * WordCamp Wrangler 91 * 92 * - Edit `wordcamp` posts on Central. 93 */ 94 case 'wordcamp_wrangler' : 95 // These capabilities only apply on central.wordcamp.org. 96 if ( BLOG_ID_CURRENT_SITE === get_current_blog_id() ) { 97 $newcaps = array( 98 'read' => true, // Access to wp-admin. 99 'wordcamp_wrangle_wordcamps' => true, 92 100 ); 93 101 } … … 115 123 function map_subrole_caps( $primitive_caps, $meta_cap, $user_id, $args ) { 116 124 $required_caps = array(); 125 $current_user = get_user_by( 'id', $user_id ); 117 126 118 127 switch ( $meta_cap ) { 119 128 case 'wordcamp_manage_mentors' : 129 case 'wordcamp_wrangle_wordcamps' : 120 130 $required_caps[] = $meta_cap; 121 131 break; 122 132 123 // Allow mentor managers to edit WCPT posts. 124 // @todo Change the capability type of WCPT to something custom so this isn't necessary. 125 case 'edit_post' : 126 case 'edit_others_posts' : 127 if ( defined( 'WCPT_POST_TYPE_ID' ) && current_user_can( 'wordcamp_manage_mentors' ) ) { 128 if ( ! empty( $args ) ) { 129 $post_type = get_post_type( $args[0] ); 130 } else { 131 $post_type = get_post_type(); 132 } 133 134 if ( WCPT_POST_TYPE_ID === $post_type ) { 135 $wcpt = get_post_type_object( WCPT_POST_TYPE_ID ); 136 $required_caps[] = $wcpt->cap->edit_posts; 137 } 133 // Allow WordCamp Wranglers to edit WordCamp posts. 134 case 'edit_wordcamps' : 135 case 'edit_published_wordcamps' : 136 case 'edit_wordcamp' : 137 case 'edit_others_wordcamps' : 138 if ( $current_user->has_cap( 'wordcamp_wrangle_wordcamps' ) ) { 139 $required_caps[] = 'wordcamp_wrangle_wordcamps'; 138 140 } 139 141 break; 140 142 141 // Allow Jetpack Connectors to do connector stuff without needing caps like `manage_network_plugins`. 142 // See Jetpack::jetpack_custom_caps() 143 case 'jetpack_connect': 144 case 'jetpack_reconnect': 145 case 'jetpack_disconnect': 146 case 'jetpack_network_admin_page': 147 case 'jetpack_network_sites_page': 148 case 'jetpack_manage_modules': 149 if ( has_subrole( get_current_user_id(), 'jetpack_connector' ) ) { 150 $required_caps[] = $meta_cap; 143 // WP_Posts_List_Table checks the `edit_post` cap regardless of post type :/ 144 case 'edit_post' : 145 if ( ! empty( $args ) ) { 146 $post_type = get_post_type( $args[0] ); 147 } else { 148 $post_type = get_post_type(); 149 } 150 151 if ( defined( 'WCPT_POST_TYPE_ID' ) && WCPT_POST_TYPE_ID === $post_type ) { 152 if ( $current_user->has_cap( 'wordcamp_wrangle_wordcamps' ) ) { 153 $required_caps[] = 'wordcamp_wrangle_wordcamps'; 154 } 151 155 } 152 156 break;
Note: See TracChangeset
for help on using the changeset viewer.