summaryrefslogtreecommitdiff
blob: 31a42117cc2e7fa4a225c1f93cd3eed9190f6637 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php  // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
 * SAL_Platform class which defines a token to later be associated with a Jetpack site
 *
 * @package automattic/jetpack
 */

require_once __DIR__ . '/class.json-api-token.php';

/**
 * Base class for SAL_Platform
 */
abstract class SAL_Platform {
	/**
	 * A token that will represent a SAL_Token instance, default is empty.
	 *
	 * @var SAL_Token
	 */
	public $token;

	/**
	 * Contructs the SAL_Platform instance
	 *
	 * @param SAL_Token $token The variable which will store the SAL_Token instance.
	 */
	public function __construct( $token ) {
		if ( is_array( $token ) ) {
			$token = SAL_Token::from_rest_token( $token );
		} else {
			$token = SAL_Token::for_anonymous_user();
		}

		$this->token = $token;
	}

	/**
	 * This is the get_site function declaration, initially not implemented.
	 *
	 * @param int $blog_id The sites Jetpack blog ID.
	 * @see class.json-api-platform-jetpack.php for the implementation of this function.
	 */
	abstract public function get_site( $blog_id );
}

if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
	require_once __DIR__ . '/class.json-api-platform-wpcom.php';
} else {
	require_once __DIR__ . '/class.json-api-platform-jetpack.php';
}