PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 2.4.7
Jetpack – WP Security, Backup, Speed, & Growth v2.4.7
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / class.jetpack-data.php

class.jetpack-data.php in Jetpack – WP Security, Backup, Speed, & Growth 2.4.7, at class.jetpack-data.php

43 lines 959 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Jetpack_Data {
4 /**
5 * Gets locally stored token
6 *
7 * @return object|false
8 */
9 public static function get_access_token( $user_id = false ) {
10 if ( $user_id ) {
11 if ( !$tokens = Jetpack::get_option( 'user_tokens' ) ) {
12 return false;
13 }
14 if ( $user_id === JETPACK_MASTER_USER ) {
15 if ( !$user_id = Jetpack::get_option( 'master_user' ) ) {
16 return false;
17 }
18 }
19 if ( !isset( $tokens[$user_id] ) || !$token = $tokens[$user_id] ) {
20 return false;
21 }
22 $token_chunks = explode( '.', $token );
23 if ( empty( $token_chunks[1] ) || empty( $token_chunks[2] ) ) {
24 return false;
25 }
26 if ( $user_id != $token_chunks[2] ) {
27 return false;
28 }
29 $token = "{$token_chunks[0]}.{$token_chunks[1]}";
30 } else {
31 $token = Jetpack::get_option( 'blog_token' );
32 if ( empty( $token ) ) {
33 return false;
34 }
35 }
36
37 return (object) array(
38 'secret' => $token,
39 'external_user_id' => (int) $user_id,
40 );
41 }
42 }
43