@@ 559-567 (lines=9) @@ | ||
556 | * |
|
557 | * @return string|int Returns the ID of the connection owner or False if no connection owner found. |
|
558 | */ |
|
559 | public function get_connection_owner_id() { |
|
560 | $user_token = $this->get_access_token( self::JETPACK_MASTER_USER ); |
|
561 | $connection_owner = false; |
|
562 | if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
|
563 | $connection_owner = $user_token->external_user_id; |
|
564 | } |
|
565 | ||
566 | return $connection_owner; |
|
567 | } |
|
568 | ||
569 | /** |
|
570 | * Returns an array of user_id's that have user tokens for communicating with wpcom. |
|
@@ 634-643 (lines=10) @@ | ||
631 | * |
|
632 | * @return object|false False if no connection owner found. |
|
633 | */ |
|
634 | public function get_connection_owner() { |
|
635 | $user_token = $this->get_access_token( self::JETPACK_MASTER_USER ); |
|
636 | ||
637 | $connection_owner = false; |
|
638 | if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
|
639 | $connection_owner = get_userdata( $user_token->external_user_id ); |
|
640 | } |
|
641 | ||
642 | return $connection_owner; |
|
643 | } |
|
644 | ||
645 | /** |
|
646 | * Returns true if the provided user is the Jetpack connection owner. |
|
@@ 652-660 (lines=9) @@ | ||
649 | * @param Integer|Boolean $user_id the user identifier. False for current user. |
|
650 | * @return Boolean True the user the connection owner, false otherwise. |
|
651 | */ |
|
652 | public function is_connection_owner( $user_id = false ) { |
|
653 | if ( ! $user_id ) { |
|
654 | $user_id = get_current_user_id(); |
|
655 | } |
|
656 | ||
657 | $user_token = $this->get_access_token( self::JETPACK_MASTER_USER ); |
|
658 | ||
659 | return $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) && $user_id === $user_token->external_user_id; |
|
660 | } |
|
661 | ||
662 | /** |
|
663 | * Connects the user with a specified ID to a WordPress.com user using the |