| @@ 1696-1719 (lines=24) @@ | ||
| 1693 | /** | |
| 1694 | * Get the wpcom user data of the current|specified connected user. | |
| 1695 | */ | |
| 1696 | 	public static function get_connected_user_data( $user_id = null ) { | |
| 1697 | // TODO: remove in favor of Connection_Manager->get_connected_user_data | |
| 1698 | 		if ( ! $user_id ) { | |
| 1699 | $user_id = get_current_user_id(); | |
| 1700 | } | |
| 1701 | ||
| 1702 | $transient_key = "jetpack_connected_user_data_$user_id"; | |
| 1703 | ||
| 1704 | 		if ( $cached_user_data = get_transient( $transient_key ) ) { | |
| 1705 | return $cached_user_data; | |
| 1706 | } | |
| 1707 | ||
| 1708 | $xml = new Jetpack_IXR_Client( array( | |
| 1709 | 'user_id' => $user_id, | |
| 1710 | ) ); | |
| 1711 | $xml->query( 'wpcom.getUser' ); | |
| 1712 | 		if ( ! $xml->isError() ) { | |
| 1713 | $user_data = $xml->getResponse(); | |
| 1714 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); | |
| 1715 | return $user_data; | |
| 1716 | } | |
| 1717 | ||
| 1718 | return false; | |
| 1719 | } | |
| 1720 | ||
| 1721 | /** | |
| 1722 | * Get the wpcom email of the current|specified connected user. | |
| @@ 524-549 (lines=26) @@ | ||
| 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 | $xml = new \Jetpack_IXR_Client( | |
| 537 | array( | |
| 538 | 'user_id' => $user_id, | |
| 539 | ) | |
| 540 | ); | |
| 541 | $xml->query( 'wpcom.getUser' ); | |
| 542 | 		if ( ! $xml->isError() ) { | |
| 543 | $user_data = $xml->getResponse(); | |
| 544 | set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS ); | |
| 545 | return $user_data; | |
| 546 | } | |
| 547 | ||
| 548 | return false; | |
| 549 | } | |
| 550 | ||
| 551 | /** | |
| 552 | * Returns true if the provided user is the Jetpack connection owner. | |