@@ 563-588 (lines=26) @@ | ||
560 | * @param Integer $user_id the user identifier. |
|
561 | * @return Object the user object. |
|
562 | */ |
|
563 | public function get_connected_user_data( $user_id = null ) { |
|
564 | if ( ! $user_id ) { |
|
565 | $user_id = get_current_user_id(); |
|
566 | } |
|
567 | ||
568 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
569 | $cached_user_data = get_transient( $transient_key ); |
|
570 | ||
571 | if ( $cached_user_data ) { |
|
572 | return $cached_user_data; |
|
573 | } |
|
574 | ||
575 | $xml = new \Jetpack_IXR_Client( |
|
576 | array( |
|
577 | 'user_id' => $user_id, |
|
578 | ) |
|
579 | ); |
|
580 | $xml->query( 'wpcom.getUser' ); |
|
581 | if ( ! $xml->isError() ) { |
|
582 | $user_data = $xml->getResponse(); |
|
583 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
584 | return $user_data; |
|
585 | } |
|
586 | ||
587 | return false; |
|
588 | } |
|
589 | ||
590 | /** |
|
591 | * Returns a user object of the connection owner. |
@@ 1688-1711 (lines=24) @@ | ||
1685 | /** |
|
1686 | * Get the wpcom user data of the current|specified connected user. |
|
1687 | */ |
|
1688 | public static function get_connected_user_data( $user_id = null ) { |
|
1689 | // TODO: remove in favor of Connection_Manager->get_connected_user_data |
|
1690 | if ( ! $user_id ) { |
|
1691 | $user_id = get_current_user_id(); |
|
1692 | } |
|
1693 | ||
1694 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
1695 | ||
1696 | if ( $cached_user_data = get_transient( $transient_key ) ) { |
|
1697 | return $cached_user_data; |
|
1698 | } |
|
1699 | ||
1700 | $xml = new Jetpack_IXR_Client( array( |
|
1701 | 'user_id' => $user_id, |
|
1702 | ) ); |
|
1703 | $xml->query( 'wpcom.getUser' ); |
|
1704 | if ( ! $xml->isError() ) { |
|
1705 | $user_data = $xml->getResponse(); |
|
1706 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
1707 | return $user_data; |
|
1708 | } |
|
1709 | ||
1710 | return false; |
|
1711 | } |
|
1712 | ||
1713 | /** |
|
1714 | * Get the wpcom email of the current|specified connected user. |