| 1 |
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 |
/** |
| 3 |
* SAL_Platform class which defines a token to later be associated with a Jetpack site |
| 4 |
* |
| 5 |
* @package automattic/jetpack |
| 6 |
*/ |
| 7 |
|
| 8 |
require_once __DIR__ . '/class.json-api-token.php'; |
| 9 |
|
| 10 |
/** |
| 11 |
* Base class for SAL_Platform |
| 12 |
*/ |
| 13 |
abstract class SAL_Platform { |
| 14 |
/** |
| 15 |
* A token that will represent a SAL_Token instance, default is empty. |
| 16 |
* |
| 17 |
* @var SAL_Token |
| 18 |
*/ |
| 19 |
public $token; |
| 20 |
|
| 21 |
/** |
| 22 |
* Contructs the SAL_Platform instance |
| 23 |
* |
| 24 |
* @param SAL_Token $token The variable which will store the SAL_Token instance. |
| 25 |
*/ |
| 26 |
public function __construct( $token ) { |
| 27 |
if ( is_array( $token ) ) { |
| 28 |
$token = SAL_Token::from_rest_token( $token ); |
| 29 |
} else { |
| 30 |
$token = SAL_Token::for_anonymous_user(); |
| 31 |
} |
| 32 |
|
| 33 |
$this->token = $token; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* This is the get_site function declaration, initially not implemented. |
| 38 |
* |
| 39 |
* @param int $blog_id The sites Jetpack blog ID. |
| 40 |
* @see class.json-api-platform-jetpack.php for the implementation of this function. |
| 41 |
*/ |
| 42 |
abstract public function get_site( $blog_id ); |
| 43 |
} |
| 44 |
|
| 45 |
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
| 46 |
require_once dirname( WP_CONTENT_DIR ) . '/public.api/rest/sal/class.json-api-platform-wpcom.php'; |
| 47 |
} else { |
| 48 |
require_once __DIR__ . '/class.json-api-platform-jetpack.php'; |
| 49 |
} |
| 50 |
|