@@ 527-535 (lines=9) @@ | ||
524 | * |
|
525 | * @return string|int Returns the ID of the connection owner or False if no connection owner found. |
|
526 | */ |
|
527 | public function get_connection_owner_id() { |
|
528 | $user_token = $this->get_access_token( JETPACK_MASTER_USER ); |
|
529 | $connection_owner = false; |
|
530 | if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
|
531 | $connection_owner = $user_token->external_user_id; |
|
532 | } |
|
533 | ||
534 | return $connection_owner; |
|
535 | } |
|
536 | ||
537 | /** |
|
538 | * Returns an array of user_id's that have user tokens for communicating with wpcom. |
|
@@ 602-611 (lines=10) @@ | ||
599 | * |
|
600 | * @return object|false False if no connection owner found. |
|
601 | */ |
|
602 | public function get_connection_owner() { |
|
603 | $user_token = $this->get_access_token( JETPACK_MASTER_USER ); |
|
604 | ||
605 | $connection_owner = false; |
|
606 | if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
|
607 | $connection_owner = get_userdata( $user_token->external_user_id ); |
|
608 | } |
|
609 | ||
610 | return $connection_owner; |
|
611 | } |
|
612 | ||
613 | /** |
|
614 | * Returns true if the provided user is the Jetpack connection owner. |
|
@@ 620-628 (lines=9) @@ | ||
617 | * @param Integer|Boolean $user_id the user identifier. False for current user. |
|
618 | * @return Boolean True the user the connection owner, false otherwise. |
|
619 | */ |
|
620 | public function is_connection_owner( $user_id = false ) { |
|
621 | if ( ! $user_id ) { |
|
622 | $user_id = get_current_user_id(); |
|
623 | } |
|
624 | ||
625 | $user_token = $this->get_access_token( JETPACK_MASTER_USER ); |
|
626 | ||
627 | return $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) && $user_id === $user_token->external_user_id; |
|
628 | } |
|
629 | ||
630 | /** |
|
631 | * Unlinks the current user from the linked WordPress.com user. |