@@ 72-97 (lines=26) @@ | ||
69 | * @param Integer $user_id the user identifier. |
|
70 | * @return Object the user object. |
|
71 | */ |
|
72 | public function get_connected_user_data( $user_id = null ) { |
|
73 | if ( ! $user_id ) { |
|
74 | $user_id = get_current_user_id(); |
|
75 | } |
|
76 | ||
77 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
78 | ||
79 | if ( $cached_user_data = get_transient( $transient_key ) ) { |
|
80 | return $cached_user_data; |
|
81 | } |
|
82 | ||
83 | \Jetpack::load_xml_rpc_client(); |
|
84 | $xml = new \Jetpack_IXR_Client( |
|
85 | array( |
|
86 | 'user_id' => $user_id, |
|
87 | ) |
|
88 | ); |
|
89 | $xml->query( 'wpcom.getUser' ); |
|
90 | if ( ! $xml->isError() ) { |
|
91 | $user_data = $xml->getResponse(); |
|
92 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
93 | return $user_data; |
|
94 | } |
|
95 | ||
96 | return false; |
|
97 | } |
|
98 | ||
99 | /** |
|
100 | * Is the user the connection owner. |
@@ 1717-1741 (lines=25) @@ | ||
1714 | /** |
|
1715 | * Get the wpcom user data of the current|specified connected user. |
|
1716 | */ |
|
1717 | public static function get_connected_user_data( $user_id = null ) { |
|
1718 | // TODO: remove in favor of Connection_Manager->get_connected_user_data |
|
1719 | if ( ! $user_id ) { |
|
1720 | $user_id = get_current_user_id(); |
|
1721 | } |
|
1722 | ||
1723 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
1724 | ||
1725 | if ( $cached_user_data = get_transient( $transient_key ) ) { |
|
1726 | return $cached_user_data; |
|
1727 | } |
|
1728 | ||
1729 | Jetpack::load_xml_rpc_client(); |
|
1730 | $xml = new Jetpack_IXR_Client( array( |
|
1731 | 'user_id' => $user_id, |
|
1732 | ) ); |
|
1733 | $xml->query( 'wpcom.getUser' ); |
|
1734 | if ( ! $xml->isError() ) { |
|
1735 | $user_data = $xml->getResponse(); |
|
1736 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
1737 | return $user_data; |
|
1738 | } |
|
1739 | ||
1740 | return false; |
|
1741 | } |
|
1742 | ||
1743 | /** |
|
1744 | * Get the wpcom email of the current|specified connected user. |