@@ 520-528 (lines=9) @@ | ||
517 | * |
|
518 | * @return string|int Returns the ID of the connection owner or False if no connection owner found. |
|
519 | */ |
|
520 | public function get_connection_owner_id() { |
|
521 | $user_token = $this->get_access_token( JETPACK_MASTER_USER ); |
|
522 | $connection_owner = false; |
|
523 | if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
|
524 | $connection_owner = $user_token->external_user_id; |
|
525 | } |
|
526 | ||
527 | return $connection_owner; |
|
528 | } |
|
529 | ||
530 | /** |
|
531 | * Returns an array of user_id's that have user tokens for communicating with wpcom. |
|
@@ 595-604 (lines=10) @@ | ||
592 | * |
|
593 | * @return object|false False if no connection owner found. |
|
594 | */ |
|
595 | public function get_connection_owner() { |
|
596 | $user_token = $this->get_access_token( JETPACK_MASTER_USER ); |
|
597 | ||
598 | $connection_owner = false; |
|
599 | if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
|
600 | $connection_owner = get_userdata( $user_token->external_user_id ); |
|
601 | } |
|
602 | ||
603 | return $connection_owner; |
|
604 | } |
|
605 | ||
606 | /** |
|
607 | * Returns true if the provided user is the Jetpack connection owner. |
|
@@ 613-621 (lines=9) @@ | ||
610 | * @param Integer|Boolean $user_id the user identifier. False for current user. |
|
611 | * @return Boolean True the user the connection owner, false otherwise. |
|
612 | */ |
|
613 | public function is_connection_owner( $user_id = false ) { |
|
614 | if ( ! $user_id ) { |
|
615 | $user_id = get_current_user_id(); |
|
616 | } |
|
617 | ||
618 | $user_token = $this->get_access_token( JETPACK_MASTER_USER ); |
|
619 | ||
620 | return $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) && $user_id === $user_token->external_user_id; |
|
621 | } |
|
622 | ||
623 | /** |
|
624 | * Unlinks the current user from the linked WordPress.com user. |