@@ 474-500 (lines=27) @@ | ||
471 | * @param Integer $user_id the user identifier. |
|
472 | * @return Object the user object. |
|
473 | */ |
|
474 | public function get_connected_user_data( $user_id = null ) { |
|
475 | if ( ! $user_id ) { |
|
476 | $user_id = get_current_user_id(); |
|
477 | } |
|
478 | ||
479 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
480 | $cached_user_data = get_transient( $transient_key ); |
|
481 | ||
482 | if ( $cached_user_data ) { |
|
483 | return $cached_user_data; |
|
484 | } |
|
485 | ||
486 | \Jetpack::load_xml_rpc_client(); |
|
487 | $xml = new \Jetpack_IXR_Client( |
|
488 | array( |
|
489 | 'user_id' => $user_id, |
|
490 | ) |
|
491 | ); |
|
492 | $xml->query( 'wpcom.getUser' ); |
|
493 | if ( ! $xml->isError() ) { |
|
494 | $user_data = $xml->getResponse(); |
|
495 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
496 | return $user_data; |
|
497 | } |
|
498 | ||
499 | return false; |
|
500 | } |
|
501 | ||
502 | /** |
|
503 | * Is the user the connection owner. |
@@ 1571-1595 (lines=25) @@ | ||
1568 | /** |
|
1569 | * Get the wpcom user data of the current|specified connected user. |
|
1570 | */ |
|
1571 | public static function get_connected_user_data( $user_id = null ) { |
|
1572 | // TODO: remove in favor of Connection_Manager->get_connected_user_data |
|
1573 | if ( ! $user_id ) { |
|
1574 | $user_id = get_current_user_id(); |
|
1575 | } |
|
1576 | ||
1577 | $transient_key = "jetpack_connected_user_data_$user_id"; |
|
1578 | ||
1579 | if ( $cached_user_data = get_transient( $transient_key ) ) { |
|
1580 | return $cached_user_data; |
|
1581 | } |
|
1582 | ||
1583 | Jetpack::load_xml_rpc_client(); |
|
1584 | $xml = new Jetpack_IXR_Client( array( |
|
1585 | 'user_id' => $user_id, |
|
1586 | ) ); |
|
1587 | $xml->query( 'wpcom.getUser' ); |
|
1588 | if ( ! $xml->isError() ) { |
|
1589 | $user_data = $xml->getResponse(); |
|
1590 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); |
|
1591 | return $user_data; |
|
1592 | } |
|
1593 | ||
1594 | return false; |
|
1595 | } |
|
1596 | ||
1597 | /** |
|
1598 | * Get the wpcom email of the current|specified connected user. |