<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
* This file defines the base class for the Site Abstraction Layer (SAL).
* Note that this is the site "as seen by user $user_id with token $token", which
* is why we pass the token to the platform; these site instances are value objects
* to be used in the context of a single request for a single user.
* Also note that at present this class _assumes_ you've "switched to"
* the site in question, and functions like `get_bloginfo( 'name' )` will
* therefore return the correct value.
* @package automattic/jetpack
use Automattic\Jetpack\Blaze;
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Status\Host;
if ( ! defined( 'ABSPATH' ) ) {
require_once __DIR__ . '/class.json-api-date.php';
require_once __DIR__ . '/class.json-api-post-base.php';
* Base class for SAL_Site.
* The abstract functions here are extended by Abstract_Jetpack_Site in class.json-api-site-jetpack-base.php.
abstract class SAL_Site {
* The Jetpack blog ID for the site.
* A new WPORG_Platform instance.
* @see class.json-api-platform-jetpack.php.
* Contructs the SAL_Site instance.
* @param int $blog_id The Jetpack blog ID for the site.
* @param WPORG_Platform $platform A new WPORG_Platform instance.
public function __construct( $blog_id, $platform ) {
$this->blog_id = $blog_id;
$this->platform = $platform;
* Get the blog_id property.
public function get_id() {
public function get_slug() {
return ( new Status() )->get_site_suffix();
public function get_name() {
return (string) htmlspecialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
* Returns the site description.
public function get_description() {
return (string) htmlspecialchars_decode( get_bloginfo( 'description' ), ENT_QUOTES );
* Returns the URL for the current site.
public function get_url() {
return (string) home_url();
* Returns the number of published posts with the 'post' post-type.
public function get_post_count() {
return (int) wp_count_posts( 'post' )->publish;
* A prototype function for get_quota - currently returns null.
public function get_quota() {
* Returns an array of blogging prompt settings. Only applicable on WordPress.com.
* Data comes from .com since the fearture requires a .com connection to work.
* @param int $user_id the current user_id.
* @param int $blog_id the blog id in this context.
public function get_blogging_prompts_settings( $user_id, $blog_id ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
* Returns true if a site has the 'videopress' option enabled, false otherwise.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function has_videopress();
* Returns VideoPress storage used, in MB.
* @see class.json-api-site-jetpack-shadow.php on WordPress.com for implementation. Only applicable on WordPress.com.
abstract public function get_videopress_storage_used();
* Sets the upgraded_filetypes_enabled Jetpack option to true as a default. Only relevant for WordPress.com sites.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function upgraded_filetypes_enabled();
* Sets the is_mapped_domain Jetpack option to true as a default.
* Primarily used in WordPress.com to confirm the current blog's domain does or doesn't match the primary redirect.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_mapped_domain();
* Fallback to the home URL since all Jetpack sites don't have an unmapped *.wordpress.com domain.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_unmapped_url();
* Whether the domain is a site redirect or not. Defaults to false on a Jetpack site.
* Primarily used in WordPress.com where it is determined if a HTTP status check is a redirect or not and whether an exception should be thrown.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_redirect();
* Defaults to false on Jetpack sites, however is used on WordPress.com sites, where it returns true if the headstart-fresh blog sticker is present.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_headstart_fresh();
* If the site's current theme supports post thumbnails, return true (otherwise return false).
* @see class.json-api-site-jetpack-base.php for implementation.
abstract public function featured_images_enabled();
* Whether or not the Jetpack 'wordads' module is active on the site.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function has_wordads();
* Defaults to false on Jetpack sites, however is used on WordPress.com sites. This nonce is used for previews on Jetpack sites.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_frame_nonce();
* Defaults to false on Jetpack sites, however is used on WordPress.com sites where
* it creates a nonce to be used with iframed block editor requests to a Jetpack site.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_jetpack_frame_nonce();
* Returns the allowed mime types and file extensions for a site.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function allowed_file_types();
* Returns an array of supported post formats.
* @see class.json-api-site-jetpack-base.php for implementation.
abstract public function get_post_formats();
* Return site's privacy status.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_private();
* Return site's coming soon status.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_coming_soon();
* Whether or not the current user is following this blog. Defaults to false.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_following();
* Defaults to 0 for the number of WordPress.com subscribers - this is filled in on the WordPress.com side.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_subscribers_count();
* Returns the language code for the current site.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_locale();
* The flag indicates that the site has Jetpack installed.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_jetpack();
* The flag indicates that the site is connected to WP.com via Jetpack Connection.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_jetpack_connection();
* This function returns the values of any active Jetpack modules.
* @see class.json-api-site-jetpack-base.php for implementation.
abstract public function get_jetpack_modules();
* This function returns true if a specified Jetpack module is active, false otherwise.
* @see class.json-api-site-jetpack-base.php for implementation.
* @param string $module The Jetpack module name to check.
abstract public function is_module_active( $module );
* This function returns false for a check as to whether a site is a VIP site or not.
* @see class.json-api-site-jetpack-base.php for implementation.
abstract public function is_vip();
* Returns true if Multisite is enabled, false otherwise.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_multisite();
* Points to the user ID of the site owner
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_site_owner();
* Returns true if the current site is a single user site, false otherwise.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_single_user_site();
* Defaults to false instead of returning the current site plan.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_plan();
* Empty function declaration - this function is filled out on the WordPress.com side, returning true if the site has an AK / VP bundle.
* @see class.json-api-site-jetpack.php and /wpcom/public.api/rest/sal/class.json-api-site-jetpack-shadow.php.
abstract public function get_ak_vp_bundle_enabled();
* Returns null for Jetpack sites. For WordPress.com sites this returns the value of the 'podcasting_archive' option.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_podcasting_archive();
* Return the last engine used for an import on the site. Not used in Jetpack.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_import_engine();
* Returns the front page meta description for current site.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_jetpack_seo_front_page_description();
* Returns custom title formats from site option.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_jetpack_seo_title_formats();
* Returns website verification codes. Allowed keys include: google, pinterest, bing, yandex, facebook.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_verification_services_codes();
* This function is implemented on WPCom sites, where a filter is removed which forces the URL to http.
* @see class.json-api-site-jetpack-base.php and /wpcom/public.api/rest/sal/class.json-api-site-jetpack-shadow.php.
abstract public function before_render();
* If a user has manage options permissions and the site is the main site of the network, make updates visible.
* Called after response_keys have been rendered, which itself is used to return all the necessary information for a site’s response.
* @see class.json-api-site-jetpack-base.php for implementation.
* @param array $response an array of the response keys.
abstract public function after_render( &$response );
* Extends the Jetpack options array with details including site constraints, WordPress and Jetpack versions, and plugins using the Jetpack connection.
* @see class.json-api-site-jetpack-base.php for implementation.
* @todo factor this out? Seems an odd thing to have on a site
* @param array $options an array of the Jetpack options.
abstract public function after_render_options( &$options );
* Wrap a WP_Post object with SAL methods, returning a Jetpack_Post object.
* @see class.json-api-site-jetpack.php for implementation.
* @param WP_Post $post A WP_Post object.
* @param string $context The post request context (for example 'edit' or 'display').
abstract public function wrap_post( $post, $context );
* For Jetpack sites this will always return false.
* @see class.json-api-site-jetpack-base.php for implementation.
* @param int $post_id The post id.
abstract protected function is_a8c_publication( $post_id );
* Return the user interactions with a site. Not used in Jetpack.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function get_user_interactions();
* Flag a site as deleted. Not used in Jetpack.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_deleted();
* Indicates that a site is an A4A client. Not used in Jetpack.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_a4a_client();
* Indicates that a site is an A4A dev site.
public function is_a4a_dev_site() {
if ( function_exists( 'has_blog_sticker' ) ) {
return has_blog_sticker( 'a4a-is-dev-site' );
* Return the user interactions with a site. Not used in Jetpack.
* @param string $role The capability to check.
* @see class.json-api-site-jetpack.php for implementation.
* @see class.json-api-site-wpcom.php (on WPCOM) for Simple-site implementation.
* @see class.json-api-site-jetpack-shadow.php (on WPCOM) for Atomic-site implementation.
abstract public function current_user_can( $role );
* Defines a filter to set whether a site is an automated_transfer site or not.
public function is_automated_transfer() {
* Filter if a site is an automated-transfer site.
* @param bool is_automated_transfer( $this->blog_id )
* @param int $blog_id Blog identifier.
'jetpack_site_automated_transfer',
* Defaulting to false and not relevant for Jetpack sites, this is expanded on the WordPress.com side for a specific wp.com/start 'WP for teams' flow.
* @see class.json-api-site-jetpack.php for implementation.
abstract public function is_wpforteams_site();
* Get hub blog id for P2 sites.
public function get_p2_hub_blog_id() {