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