| @@ -1,0 +1,53 @@ | ||
| 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 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 9 | + exit( 0 ); | |
| 10 | +} | |
| 11 | + | |
| 12 | +require_once __DIR__ . '/class.json-api-token.php'; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * Base class for SAL_Platform | |
| 16 | + */ | |
| 17 | +abstract class SAL_Platform { | |
| 18 | + /** | |
| 19 | + * A token that will represent a SAL_Token instance, default is empty. | |
| 20 | + * | |
| 21 | + * @var SAL_Token | |
| 22 | + */ | |
| 23 | + public $token; | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * Contructs the SAL_Platform instance | |
| 27 | + * | |
| 28 | + * @param SAL_Token $token The variable which will store the SAL_Token instance. | |
| 29 | + */ | |
| 30 | + public function __construct( $token ) { | |
| 31 | + if ( is_array( $token ) ) { | |
| 32 | + $token = SAL_Token::from_rest_token( $token ); | |
| 33 | + } else { | |
| 34 | + $token = SAL_Token::for_anonymous_user(); | |
| 35 | + } | |
| 36 | + | |
| 37 | + $this->token = $token; | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * This is the get_site function declaration, initially not implemented. | |
| 42 | + * | |
| 43 | + * @param int $blog_id The sites Jetpack blog ID. | |
| 44 | + * @see class.json-api-platform-jetpack.php for the implementation of this function. | |
| 45 | + */ | |
| 46 | + abstract public function get_site( $blog_id ); | |
| 47 | +} | |
| 48 | + | |
| 49 | +if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { | |
| 50 | + require_once dirname( WP_CONTENT_DIR ) . '/public.api/rest/sal/class.json-api-platform-wpcom.php'; | |
| 51 | +} else { | |
| 52 | + require_once __DIR__ . '/class.json-api-platform-jetpack.php'; | |
| 53 | +} | |