|
@@ 630-638 (lines=9) @@
|
| 627 |
|
* |
| 628 |
|
* @return string|int Returns the ID of the connection owner or False if no connection owner found. |
| 629 |
|
*/ |
| 630 |
|
public function get_connection_owner_id() { |
| 631 |
|
$user_token = $this->get_access_token( self::CONNECTION_OWNER ); |
| 632 |
|
$connection_owner = false; |
| 633 |
|
if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
| 634 |
|
$connection_owner = $user_token->external_user_id; |
| 635 |
|
} |
| 636 |
|
|
| 637 |
|
return $connection_owner; |
| 638 |
|
} |
| 639 |
|
|
| 640 |
|
/** |
| 641 |
|
* Returns an array of user_id's that have user tokens for communicating with wpcom. |
|
@@ 708-717 (lines=10) @@
|
| 705 |
|
* |
| 706 |
|
* @return object|false False if no connection owner found. |
| 707 |
|
*/ |
| 708 |
|
public function get_connection_owner() { |
| 709 |
|
$user_token = $this->get_access_token( self::CONNECTION_OWNER ); |
| 710 |
|
|
| 711 |
|
$connection_owner = false; |
| 712 |
|
if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
| 713 |
|
$connection_owner = get_userdata( $user_token->external_user_id ); |
| 714 |
|
} |
| 715 |
|
|
| 716 |
|
return $connection_owner; |
| 717 |
|
} |
| 718 |
|
|
| 719 |
|
/** |
| 720 |
|
* Returns true if the provided user is the Jetpack connection owner. |
|
@@ 726-734 (lines=9) @@
|
| 723 |
|
* @param Integer|Boolean $user_id the user identifier. False for current user. |
| 724 |
|
* @return Boolean True the user the connection owner, false otherwise. |
| 725 |
|
*/ |
| 726 |
|
public function is_connection_owner( $user_id = false ) { |
| 727 |
|
if ( ! $user_id ) { |
| 728 |
|
$user_id = get_current_user_id(); |
| 729 |
|
} |
| 730 |
|
|
| 731 |
|
$user_token = $this->get_access_token( self::CONNECTION_OWNER ); |
| 732 |
|
|
| 733 |
|
return $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) && $user_id === $user_token->external_user_id; |
| 734 |
|
} |
| 735 |
|
|
| 736 |
|
/** |
| 737 |
|
* Connects the user with a specified ID to a WordPress.com user using the |