Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Roles::get_post_type_caps( string $role )
Retrieve the post type specific capabilities for a give role.
Parameters Parameters
- $role
-
(string) (Required) Name of the role
Return Return
(array)
Source Source
File: includes/class.llms.roles.php
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | private static function get_post_type_caps( $role ) { $caps = array (); // Students get nothing. if ( 'student' !== $role ) { $post_types = array ( 'course' => 'course' , 'lesson' => 'lesson' , 'llms_quiz' => array ( 'quiz' , 'quizzes' ), 'llms_question' => 'question' , 'llms_membership' => 'membership' , ); foreach ( $post_types as $post_type => $names ) { $post_caps = LLMS_Post_Types::get_post_type_caps( $names ); // Filter the caps down for these roles. if ( in_array( $role , array ( 'instructor' , 'instructors_assistant' ), true ) ) { $allowed = array ( 'instructor' => array ( 'delete_posts' , 'delete_published_posts' , 'edit_post' , 'edit_posts' , 'edit_published_posts' , 'publish_posts' , 'create_posts' , ), 'instructors_assistant' => array ( 'edit_post' , 'edit_posts' , 'edit_published_posts' , ), ); foreach ( $post_caps as $post_cap => $cpt_cap ) { if ( ! in_array( $post_cap , $allowed [ $role ], true ) ) { unset( $post_caps [ $post_cap ] ); } } } $caps [ $post_type ] = array_fill_keys( array_values ( $post_caps ), true ); } $taxes = array ( 'course_cat' => 'course_cat' , 'course_difficulty' => array ( 'course_difficulty' , 'course_difficulties' ), 'course_tag' => 'course_tag' , 'course_track' => 'course_track' , 'membership_cat' => 'membership_cat' , 'membership_tag' => 'membership_tag' , ); foreach ( $taxes as $tax => $names ) { $tax_caps = LLMS_Post_Types::get_tax_caps( $names ); // Filter the caps down for these roles. if ( in_array( $role , array ( 'instructor' , 'instructors_assistant' ), true ) ) { $allowed = array ( 'assign_terms' , ); foreach ( $tax_caps as $tax_cap => $ct_cap ) { if ( ! in_array( $tax_cap , $allowed , true ) ) { unset( $tax_caps [ $tax_cap ] ); } } } $caps [ $tax ] = array_fill_keys( array_values ( $tax_caps ), true ); } } return apply_filters( 'llms_get_' . $role . '_post_type_caps' , $caps ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
4.21.2 | Use strict comparisons for in_array() . |
3.13.0 | Introduced. |