@@ 592-605 (lines=14) @@ | ||
589 | * @param string $capability Capability or role name. |
|
590 | * @return bool |
|
591 | */ |
|
592 | function author_can( $post, $capability ) { |
|
593 | if ( !$post = get_post($post) ) |
|
594 | return false; |
|
595 | ||
596 | $author = get_userdata( $post->post_author ); |
|
597 | ||
598 | if ( ! $author ) |
|
599 | return false; |
|
600 | ||
601 | $args = array_slice( func_get_args(), 2 ); |
|
602 | $args = array_merge( array( $capability ), $args ); |
|
603 | ||
604 | return call_user_func_array( array( $author, 'has_cap' ), $args ); |
|
605 | } |
|
606 | ||
607 | /** |
|
608 | * Whether a particular user has capability or role. |
|
@@ 616-627 (lines=12) @@ | ||
613 | * @param string $capability Capability or role name. |
|
614 | * @return bool |
|
615 | */ |
|
616 | function user_can( $user, $capability ) { |
|
617 | if ( ! is_object( $user ) ) |
|
618 | $user = get_userdata( $user ); |
|
619 | ||
620 | if ( ! $user || ! $user->exists() ) |
|
621 | return false; |
|
622 | ||
623 | $args = array_slice( func_get_args(), 2 ); |
|
624 | $args = array_merge( array( $capability ), $args ); |
|
625 | ||
626 | return call_user_func_array( array( $user, 'has_cap' ), $args ); |
|
627 | } |
|
628 | ||
629 | /** |
|
630 | * Retrieves the global WP_Roles instance and instantiates it if necessary. |