@@ 228-242 (lines=15) @@ | ||
225 | return $post; |
|
226 | } |
|
227 | ||
228 | public function current_user_can_access_post_type( $post_type, $context ) { |
|
229 | $post_type_object = $this->get_post_type_object( $post_type ); |
|
230 | if ( ! $post_type_object ) { |
|
231 | return false; |
|
232 | } |
|
233 | ||
234 | switch( $context ) { |
|
235 | case 'edit': |
|
236 | return current_user_can( $post_type_object->cap->edit_posts ); |
|
237 | case 'display': |
|
238 | return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts ); |
|
239 | default: |
|
240 | return false; |
|
241 | } |
|
242 | } |
|
243 | ||
244 | protected function get_post_type_object( $post_type ) { |
|
245 | return get_post_type_object( $post_type ); |
@@ 1754-1768 (lines=15) @@ | ||
1751 | * @param string $context 'display' or 'edit' |
|
1752 | * @return bool |
|
1753 | */ |
|
1754 | function current_user_can_access_post_type( $post_type, $context = 'display' ) { |
|
1755 | $post_type_object = get_post_type_object( $post_type ); |
|
1756 | if ( ! $post_type_object ) { |
|
1757 | return false; |
|
1758 | } |
|
1759 | ||
1760 | switch ( $context ) { |
|
1761 | case 'edit': |
|
1762 | return current_user_can( $post_type_object->cap->edit_posts ); |
|
1763 | case 'display': |
|
1764 | return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts ); |
|
1765 | default: |
|
1766 | return false; |
|
1767 | } |
|
1768 | } |
|
1769 | ||
1770 | function is_post_type_allowed( $post_type ) { |
|
1771 | // if the post type is empty, that's fine, WordPress will default to post |