|
@@ 577-585 (lines=9) @@
|
| 574 |
|
* |
| 575 |
|
* @return string|int Returns the ID of the connection owner or False if no connection owner found. |
| 576 |
|
*/ |
| 577 |
|
public function get_connection_owner_id() { |
| 578 |
|
$user_token = $this->get_access_token( self::JETPACK_MASTER_USER ); |
| 579 |
|
$connection_owner = false; |
| 580 |
|
if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
| 581 |
|
$connection_owner = $user_token->external_user_id; |
| 582 |
|
} |
| 583 |
|
|
| 584 |
|
return $connection_owner; |
| 585 |
|
} |
| 586 |
|
|
| 587 |
|
/** |
| 588 |
|
* Returns an array of user_id's that have user tokens for communicating with wpcom. |
|
@@ 652-661 (lines=10) @@
|
| 649 |
|
* |
| 650 |
|
* @return object|false False if no connection owner found. |
| 651 |
|
*/ |
| 652 |
|
public function get_connection_owner() { |
| 653 |
|
$user_token = $this->get_access_token( self::JETPACK_MASTER_USER ); |
| 654 |
|
|
| 655 |
|
$connection_owner = false; |
| 656 |
|
if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) { |
| 657 |
|
$connection_owner = get_userdata( $user_token->external_user_id ); |
| 658 |
|
} |
| 659 |
|
|
| 660 |
|
return $connection_owner; |
| 661 |
|
} |
| 662 |
|
|
| 663 |
|
/** |
| 664 |
|
* Returns true if the provided user is the Jetpack connection owner. |
|
@@ 670-678 (lines=9) @@
|
| 667 |
|
* @param Integer|Boolean $user_id the user identifier. False for current user. |
| 668 |
|
* @return Boolean True the user the connection owner, false otherwise. |
| 669 |
|
*/ |
| 670 |
|
public function is_connection_owner( $user_id = false ) { |
| 671 |
|
if ( ! $user_id ) { |
| 672 |
|
$user_id = get_current_user_id(); |
| 673 |
|
} |
| 674 |
|
|
| 675 |
|
$user_token = $this->get_access_token( self::JETPACK_MASTER_USER ); |
| 676 |
|
|
| 677 |
|
return $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) && $user_id === $user_token->external_user_id; |
| 678 |
|
} |
| 679 |
|
|
| 680 |
|
/** |
| 681 |
|
* Connects the user with a specified ID to a WordPress.com user using the |