@@ 195-209 (lines=15) @@ | ||
192 | return $post; |
|
193 | } |
|
194 | ||
195 | public function current_user_can_access_post_type( $post_type, $context ) { |
|
196 | $post_type_object = $this->get_post_type_object( $post_type ); |
|
197 | if ( ! $post_type_object ) { |
|
198 | return false; |
|
199 | } |
|
200 | ||
201 | switch( $context ) { |
|
202 | case 'edit': |
|
203 | return current_user_can( $post_type_object->cap->edit_posts ); |
|
204 | case 'display': |
|
205 | return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts ); |
|
206 | default: |
|
207 | return false; |
|
208 | } |
|
209 | } |
|
210 | ||
211 | protected function get_post_type_object( $post_type ) { |
|
212 | return get_post_type_object( $post_type ); |
@@ 1688-1702 (lines=15) @@ | ||
1685 | * @param string $context 'display' or 'edit' |
|
1686 | * @return bool |
|
1687 | */ |
|
1688 | function current_user_can_access_post_type( $post_type, $context='display' ) { |
|
1689 | $post_type_object = get_post_type_object( $post_type ); |
|
1690 | if ( ! $post_type_object ) { |
|
1691 | return false; |
|
1692 | } |
|
1693 | ||
1694 | switch( $context ) { |
|
1695 | case 'edit': |
|
1696 | return current_user_can( $post_type_object->cap->edit_posts ); |
|
1697 | case 'display': |
|
1698 | return $post_type_object->public || current_user_can( $post_type_object->cap->read_private_posts ); |
|
1699 | default: |
|
1700 | return false; |
|
1701 | } |
|
1702 | } |
|
1703 | ||
1704 | function is_post_type_allowed( $post_type ) { |
|
1705 | // if the post type is empty, that's fine, WordPress will default to post |