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