@@ 524-550 (lines=27) @@ | ||
521 | * @param Integer $user_id the user identifier. |
|
522 | * @return Object the user object. |
|
523 | */ |
|
524 | public function get_connected_user_data( $user_id = null ) { |
|
525 | if ( ! $user_id ) { |
|
526 | $user_id = get_current_user_id(); |
|
527 | } |
|
528 | ||
529 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
530 | $cached_user_data = get_transient( $transient_key ); |
|
531 | ||
532 | if ( $cached_user_data ) { |
|
533 | return $cached_user_data; |
|
534 | } |
|
535 | ||
536 | \Jetpack::load_xml_rpc_client(); |
|
537 | $xml = new \Jetpack_IXR_Client( |
|
538 | array( |
|
539 | 'user_id' => $user_id, |
|
540 | ) |
|
541 | ); |
|
542 | $xml->query( 'wpcom.getUser' ); |
|
543 | if ( ! $xml->isError() ) { |
|
544 | $user_data = $xml->getResponse(); |
|
545 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
546 | return $user_data; |
|
547 | } |
|
548 | ||
549 | return false; |
|
550 | } |
|
551 | ||
552 | /** |
|
553 | * Returns true if the provided user is the Jetpack connection owner. |
@@ 1694-1718 (lines=25) @@ | ||
1691 | /** |
|
1692 | * Get the wpcom user data of the current|specified connected user. |
|
1693 | */ |
|
1694 | public static function get_connected_user_data( $user_id = null ) { |
|
1695 | // TODO: remove in favor of Connection_Manager->get_connected_user_data |
|
1696 | if ( ! $user_id ) { |
|
1697 | $user_id = get_current_user_id(); |
|
1698 | } |
|
1699 | ||
1700 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
1701 | ||
1702 | if ( $cached_user_data = get_transient( $transient_key ) ) { |
|
1703 | return $cached_user_data; |
|
1704 | } |
|
1705 | ||
1706 | Jetpack::load_xml_rpc_client(); |
|
1707 | $xml = new Jetpack_IXR_Client( array( |
|
1708 | 'user_id' => $user_id, |
|
1709 | ) ); |
|
1710 | $xml->query( 'wpcom.getUser' ); |
|
1711 | if ( ! $xml->isError() ) { |
|
1712 | $user_data = $xml->getResponse(); |
|
1713 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
1714 | return $user_data; |
|
1715 | } |
|
1716 | ||
1717 | return false; |
|
1718 | } |
|
1719 | ||
1720 | /** |
|
1721 | * Get the wpcom email of the current|specified connected user. |