<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
* This class extends the Abstract_Jetpack_Site class, which includes providing
* the implementation for functions that were declared in that class.
* @see class.json-api-site-jetpack-base.php for more context on some of
* the functions extended here.
* @package automattic/jetpack
use Automattic\Jetpack\Status\Host;
use Automattic\Jetpack\Sync\Functions;
if ( ! defined( 'ABSPATH' ) ) {
require_once __DIR__ . '/class.json-api-site-jetpack-base.php';
require_once __DIR__ . '/class.json-api-post-jetpack.php';
* Base class for Jetpack_Site. This code runs on Jetpack (.org) sites.
class Jetpack_Site extends Abstract_Jetpack_Site {
* Retrieves a Jetpack option's value, given the option name.
* @param string $name the name of the Jetpack option, without the 'jetpack' prefix (eg. 'log' for 'jetpack_log').
protected function get_mock_option( $name ) {
return get_option( 'jetpack_' . $name );
* If a Jetpack constant name has been defined, this will return the value of the constant.
* @param string $name the name of the Jetpack constant to check.
protected function get_constant( $name ) {
if ( defined( $name ) ) {
return constant( $name );
* Returns the site URL for the current network.
protected function main_network_site() {
return network_site_url();
* Returns the WordPress version for the current site.
protected function wp_version() {
* Returns the maximum upload size allowed in php.ini.
protected function max_upload_size() {
return wp_max_upload_size();
* This function returns the value of the 'WP_MEMORY_LIMIT' constant converted to an integer byte value.
protected function wp_memory_limit() {
return wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
* This function returns the value of the 'WP_MAX_MEMORY_LIMIT' constant converted to an integer byte value.
protected function wp_max_memory_limit() {
return wp_convert_hr_to_bytes( WP_MAX_MEMORY_LIMIT );
* Returns true if the site is within a system with a multiple networks, false otherwise.
* @see /projects/packages/status/src/class-status.php
protected function is_main_network() {
return Jetpack::is_multi_network();
* Returns true if Multisite is enabled, false otherwise.
public function is_multisite() {
return (bool) is_multisite();
* Returns true if the current site is a single user site, false otherwise.
public function is_single_user_site() {
return (bool) Jetpack::is_single_user_site();
* Returns true if is_vcs_checkout discovers a version control checkout, false otherwise.
* @see projects/packages/sync/src/class-functions.php.
protected function is_version_controlled() {
return Functions::is_version_controlled();
* Returns true if the site has file write access, false otherwise.
* @see projects/packages/sync/src/class-functions.php.
protected function file_system_write_access() {
return Functions::file_system_write_access();
* Returns true if the current theme supports the $feature_name, false otherwise.
* @param string $feature_name the name of the Jetpack feature.
protected function current_theme_supports( $feature_name ) {
return current_theme_supports( $feature_name );
* Gets theme support arguments to be checked against the specific Jetpack feature.
* @param string $feature_name the name of the Jetpack feature to check against.
protected function get_theme_support( $feature_name ) {
return get_theme_support( $feature_name );
* Fetch a list of active plugins that are using Jetpack Connection.
* @return array An array of active plugins (by slug) that are using Jetpack Connection.
protected function get_connection_active_plugins() {
$plugins = $this->get_mock_option( 'connection_active_plugins' );
return is_array( $plugins ) ? array_keys( $plugins ) : array();
* Gets updates and then stores them in the jetpack_updates option, returning an array with the option schema.
public function get_updates() {
return (array) Jetpack::get_updates();
* Returns the Jetpack blog ID for a site.
public function get_id() {
return $this->platform->token->blog_id;
* Returns true if a site has the 'videopress' option enabled, false otherwise.
public function has_videopress() {
// TODO - this only works on wporg site - need to detect videopress option for remote Jetpack site on WPCOM.
$videopress = Jetpack_Options::get_option( 'videopress', array() );
if ( isset( $videopress['blog_id'] ) && $videopress['blog_id'] > 0 ) {
* Returns VideoPress storage used, in MB.
* @see class.json-api-site-jetpack-shadow.php on WordPress.com for implementation. Only applicable on WordPress.com.
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 wpcom_site_has_upgraded_upload_filetypes at /wpcom/wp-content/mu-plugins/misc.php.
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 /wpcom/wp-content/mu-plugins/insecure-content-helpers.php within WordPress.com.
public function is_mapped_domain() {
* Fallback to the home URL since all Jetpack sites don't have an unmapped *.wordpress.com domain.
public function get_unmapped_url() {
// Fallback to the home URL since all Jetpack sites don't have an unmapped *.wordpress.com domain.
* 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 /wpcom/wp-includes/Requests/Response.php within WordPress.com.
public function is_redirect() {
* Whether or not the current user is following this blog. Defaults to false.
public function is_following() {
* Points to the user ID of the site owner
* @return null for Jetpack sites
public function get_site_owner() {
* Whether or not the Jetpack 'wordads' module is active on the site.
public function has_wordads() {
return Jetpack::is_module_active( 'wordads' );
* Defaults to false on Jetpack sites, however is used on WordPress.com sites. This nonce is used for previews on Jetpack sites.
* @see /wpcom/public.api/rest/sal/class.json-api-site-jetpack-shadow.php.
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 /wpcom/public.api/rest/sal/class.json-api-site-jetpack-shadow.php.
public function get_jetpack_frame_nonce() {
* 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 /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php.
public function is_headstart_fresh() {
* Returns the allowed mime types and file extensions for a site.
public function allowed_file_types() {
$allowed_file_types = array();
// https://codex.wordpress.org/Uploading_Files.
$mime_types = get_allowed_mime_types();
foreach ( $mime_types as $type => $mime_type ) {
$extras = explode( '|', $type );
foreach ( $extras as $extra ) {
$allowed_file_types[] = $extra;
return $allowed_file_types;
* Return site's privacy status.
* @return bool Is site private?
public function is_private() {
return (int) $this->get_atomic_cloud_site_option( 'blog_public' ) === -1;
* Return site's coming soon status.
* @return bool Is site "Coming soon"?
public function is_coming_soon() {
return $this->is_private() && (int) $this->get_atomic_cloud_site_option( 'wpcom_coming_soon' ) === 1;
* Return site's launch status.
* @return string|bool Launch status ('launched', 'unlaunched', or false).
public function get_launch_status() {
return $this->get_atomic_cloud_site_option( 'launch-status' );
* Given an option name, returns false if the site isn't WoA or doesn't have the ability to retrieve cloud site options.
* Otherwise, if the option name exists amongst Jetpack options, the option value is returned.
* @param string $option The option name to check.
public function get_atomic_cloud_site_option( $option ) {
if ( ! ( new Host() )->is_woa_site() ) {
$jetpack = Jetpack::init();
if ( ! method_exists( $jetpack, 'get_cloud_site_options' ) ) {
$result = $jetpack->get_cloud_site_options( array( $option ) );
if ( ! array_key_exists( $option, $result ) ) {
return $result[ $option ];
* Defaults to false instead of returning the current site plan.
public function get_plan() {
* Defaults to 0 for the number of WordPress.com subscribers - this is filled in on the WordPress.com side.
* @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php.
public function get_subscribers_count() {
* Defaults to false - this is filled on the WordPress.com side in multiple locations.
* @see WPCOM_JSON_API_GET_Site_Endpoint::decorate_jetpack_response.
public function get_capabilities() {
* Returns the language code for the current site.
public function get_locale() {
return get_bloginfo( 'language' );
* The flag indicates that the site has Jetpack installed.
public function is_jetpack() {
* The flag indicates that the site is connected to WP.com via Jetpack Connection.
public function is_jetpack_connection() {
* Returns the current site's Jetpack version.
public function get_jetpack_version() {
* Empty function declaration - this function is filled out on the WordPress.com side, returning true if the site has an AK / VP bundle.
* @see /wpcom/public.api/rest/sal/class.json-api-site-jetpack-shadow.php.
public function get_ak_vp_bundle_enabled() {}
* Returns the front page meta description for current site.
* @see /modules/seo-tools/class-jetpack-seo-utils.php.
public function get_jetpack_seo_front_page_description() {
return Jetpack_SEO_Utils::get_front_page_meta_description();
* Returns custom title formats from site option.
* @see /modules/seo-tools/class-jetpack-seo-titles.php.
public function get_jetpack_seo_title_formats() {
return Jetpack_SEO_Titles::get_custom_title_formats();