| @@ 1705-1730 (lines=26) @@ | ||
| 1702 | /** |
|
| 1703 | * Get the wpcom user data of the current|specified connected user. |
|
| 1704 | */ |
|
| 1705 | public static function get_connected_user_data( $user_id = null ) { |
|
| 1706 | // TODO: remove in favor of Connection_Manager->get_connected_user_data |
|
| 1707 | if ( ! $user_id ) { |
|
| 1708 | $user_id = get_current_user_id(); |
|
| 1709 | } |
|
| 1710 | ||
| 1711 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
| 1712 | ||
| 1713 | if ( $cached_user_data = get_transient( $transient_key ) ) { |
|
| 1714 | return $cached_user_data; |
|
| 1715 | } |
|
| 1716 | ||
| 1717 | $xml = new Jetpack_IXR_Client( array( |
|
| 1718 | 'user_id' => $user_id, |
|
| 1719 | ) ); |
|
| 1720 | $xml->query( 'wpcom.getUser' ); |
|
| 1721 | if ( ! $xml->isError() ) { |
|
| 1722 | $user_data = $xml->getResponse(); |
|
| 1723 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
| 1724 | return $user_data; |
|
| 1725 | } |
|
| 1726 | ||
| 1727 | return false; |
|
| 1728 | } |
|
| 1729 | ||
| 1730 | /** |
|
| 1731 | * Get the wpcom email of the current|specified connected user. |
|
| 1732 | */ |
|
| 1733 | public static function get_connected_user_email( $user_id = null ) { |
|
| @@ 538-563 (lines=26) @@ | ||
| 535 | * @param Integer $user_id the user identifier. |
|
| 536 | * @return Object the user object. |
|
| 537 | */ |
|
| 538 | public function get_connected_user_data( $user_id = null ) { |
|
| 539 | if ( ! $user_id ) { |
|
| 540 | $user_id = get_current_user_id(); |
|
| 541 | } |
|
| 542 | ||
| 543 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
| 544 | $cached_user_data = get_transient( $transient_key ); |
|
| 545 | ||
| 546 | if ( $cached_user_data ) { |
|
| 547 | return $cached_user_data; |
|
| 548 | } |
|
| 549 | ||
| 550 | $xml = new \Jetpack_IXR_Client( |
|
| 551 | array( |
|
| 552 | 'user_id' => $user_id, |
|
| 553 | ) |
|
| 554 | ); |
|
| 555 | $xml->query( 'wpcom.getUser' ); |
|
| 556 | if ( ! $xml->isError() ) { |
|
| 557 | $user_data = $xml->getResponse(); |
|
| 558 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
| 559 | return $user_data; |
|
| 560 | } |
|
| 561 | ||
| 562 | return false; |
|
| 563 | } |
|
| 564 | ||
| 565 | /** |
|
| 566 | * Returns true if the provided user is the Jetpack connection owner. |
|