| @@ 1570-1594 (lines=25) @@ | ||
| 1567 | /** | |
| 1568 | * Get the wpcom user data of the current|specified connected user. | |
| 1569 | */ | |
| 1570 | 	public static function get_connected_user_data( $user_id = null ) { | |
| 1571 | // TODO: remove in favor of Connection_Manager->get_connected_user_data | |
| 1572 | 		if ( ! $user_id ) { | |
| 1573 | $user_id = get_current_user_id(); | |
| 1574 | } | |
| 1575 | ||
| 1576 | $transient_key = "jetpack_connected_user_data_$user_id"; | |
| 1577 | ||
| 1578 | 		if ( $cached_user_data = get_transient( $transient_key ) ) { | |
| 1579 | return $cached_user_data; | |
| 1580 | } | |
| 1581 | ||
| 1582 | Jetpack::load_xml_rpc_client(); | |
| 1583 | $xml = new Jetpack_IXR_Client( array( | |
| 1584 | 'user_id' => $user_id, | |
| 1585 | ) ); | |
| 1586 | $xml->query( 'wpcom.getUser' ); | |
| 1587 | 		if ( ! $xml->isError() ) { | |
| 1588 | $user_data = $xml->getResponse(); | |
| 1589 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); | |
| 1590 | return $user_data; | |
| 1591 | } | |
| 1592 | ||
| 1593 | return false; | |
| 1594 | } | |
| 1595 | ||
| 1596 | /** | |
| 1597 | * Get the wpcom email of the current|specified connected user. | |
| @@ 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. | |