@@ 501-514 (lines=14) @@ | ||
498 | * @param string $capability Capability or role name. |
|
499 | * @return bool |
|
500 | */ |
|
501 | function author_can( $post, $capability ) { |
|
502 | if ( !$post = get_post($post) ) |
|
503 | return false; |
|
504 | ||
505 | $author = get_userdata( $post->post_author ); |
|
506 | ||
507 | if ( ! $author ) |
|
508 | return false; |
|
509 | ||
510 | $args = array_slice( func_get_args(), 2 ); |
|
511 | $args = array_merge( array( $capability ), $args ); |
|
512 | ||
513 | return call_user_func_array( array( $author, 'has_cap' ), $args ); |
|
514 | } |
|
515 | ||
516 | /** |
|
517 | * Whether a particular user has capability or role. |
|
@@ 525-536 (lines=12) @@ | ||
522 | * @param string $capability Capability or role name. |
|
523 | * @return bool |
|
524 | */ |
|
525 | function user_can( $user, $capability ) { |
|
526 | if ( ! is_object( $user ) ) |
|
527 | $user = get_userdata( $user ); |
|
528 | ||
529 | if ( ! $user || ! $user->exists() ) |
|
530 | return false; |
|
531 | ||
532 | $args = array_slice( func_get_args(), 2 ); |
|
533 | $args = array_merge( array( $capability ), $args ); |
|
534 | ||
535 | return call_user_func_array( array( $user, 'has_cap' ), $args ); |
|
536 | } |
|
537 | ||
538 | /** |
|
539 | * Retrieves the global WP_Roles instance and instantiates it if necessary. |