summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/sal/class.json-api-site-base.php')
-rw-r--r--plugins/jetpack/sal/class.json-api-site-base.php122
1 files changed, 104 insertions, 18 deletions
diff --git a/plugins/jetpack/sal/class.json-api-site-base.php b/plugins/jetpack/sal/class.json-api-site-base.php
index 9458f4c7..c30236ab 100644
--- a/plugins/jetpack/sal/class.json-api-site-base.php
+++ b/plugins/jetpack/sal/class.json-api-site-base.php
@@ -1,5 +1,7 @@
<?php
+use Automattic\Jetpack\Status\Host;
+
require_once dirname( __FILE__ ) . '/class.json-api-date.php';
require_once dirname( __FILE__ ) . '/class.json-api-post-base.php';
@@ -71,14 +73,28 @@ abstract class SAL_Site {
abstract public function is_private();
+ abstract public function is_coming_soon();
+
abstract public function is_following();
abstract public function get_subscribers_count();
abstract public function get_locale();
+ /**
+ * The flag indicates that the site has Jetpack installed
+ *
+ * @return bool
+ */
abstract public function is_jetpack();
+ /**
+ * The flag indicates that the site is connected to WP.com via Jetpack Connection
+ *
+ * @return bool
+ */
+ abstract public function is_jetpack_connection();
+
abstract public function get_jetpack_modules();
abstract public function is_module_active( $module );
@@ -87,6 +103,13 @@ abstract class SAL_Site {
abstract public function is_multisite();
+ /**
+ * Points to the user ID of the site owner
+ *
+ * @return int for WP.com, null for Jetpack
+ */
+ abstract public function get_site_owner();
+
abstract public function is_single_user_site();
abstract public function get_plan();
@@ -133,8 +156,33 @@ abstract class SAL_Site {
);
}
+ abstract protected function is_wpforteams_site();
+
+ /**
+ * Get hub blog id for P2 sites.
+ *
+ * @return null
+ */
+ public function get_p2_hub_blog_id() {
+ return null;
+ }
+
+ /**
+ * Getter for the p2 organization ID.
+ *
+ * @return int
+ */
+ public function get_p2_organization_id() {
+ return 0; // WPForTeams\Constants\NO_ORG_ID not loaded.
+ }
+
+ /**
+ * Detect whether a site is a WordPress.com on Atomic site.
+ *
+ * @return bool
+ */
public function is_wpcom_atomic() {
- return false;
+ return ( new Host() )->is_woa_site();
}
public function is_wpcom_store() {
@@ -145,11 +193,15 @@ abstract class SAL_Site {
return false;
}
- public function get_post_by_id( $post_id, $context ) {
- // Remove the skyword tracking shortcode for posts returned via the API.
- remove_shortcode( 'skyword-tracking' );
- add_shortcode( 'skyword-tracking', '__return_empty_string' );
+ public function is_cloud_eligible() {
+ return false;
+ }
+
+ public function get_products() {
+ return array();
+ }
+ public function get_post_by_id( $post_id, $context ) {
$post = get_post( $post_id, OBJECT, $context );
if ( ! $post ) {
@@ -400,6 +452,8 @@ abstract class SAL_Site {
}
function get_capabilities() {
+ $is_wpcom_blog_owner = wpcom_get_blog_owner() === (int) get_current_user_id();
+
return array(
'edit_pages' => current_user_can( 'edit_pages' ),
'edit_posts' => current_user_can( 'edit_posts' ),
@@ -413,12 +467,13 @@ abstract class SAL_Site {
'manage_categories' => current_user_can( 'manage_categories' ),
'manage_options' => current_user_can( 'manage_options' ),
'moderate_comments' => current_user_can( 'moderate_comments' ),
- 'activate_wordads' => wpcom_get_blog_owner() === (int) get_current_user_id(),
+ 'activate_wordads' => $is_wpcom_blog_owner,
'promote_users' => current_user_can( 'promote_users' ),
'publish_posts' => current_user_can( 'publish_posts' ),
'upload_files' => current_user_can( 'upload_files' ),
'delete_users' => current_user_can( 'delete_users' ),
'remove_users' => current_user_can( 'remove_users' ),
+ 'own_site' => $is_wpcom_blog_owner,
/**
* Filter whether the Hosting section in Calypso should be available for site.
*
@@ -429,7 +484,8 @@ abstract class SAL_Site {
* @param bool $view_hosting Can site access Hosting section. Default to false.
*/
'view_hosting' => apply_filters( 'jetpack_json_api_site_can_view_hosting', false ),
- 'view_stats' => stats_is_blog_user( $this->blog_id )
+ 'view_stats' => stats_is_blog_user( $this->blog_id ),
+ 'activate_plugins' => current_user_can( 'activate_plugins' ),
);
}
@@ -451,7 +507,6 @@ abstract class SAL_Site {
}
function get_logo() {
-
// Set an empty response array.
$logo_setting = array(
'id' => (int) 0,
@@ -460,16 +515,12 @@ abstract class SAL_Site {
);
// Get current site logo values.
- $logo = get_option( 'site_logo' );
+ $logo_id = get_option( 'site_logo' );
// Update the response array if there's a site logo currenty active.
- if ( $logo && 0 != $logo['id'] ) {
- $logo_setting['id'] = $logo['id'];
- $logo_setting['url'] = $logo['url'];
-
- foreach ( $logo['sizes'] as $size => $properties ) {
- $logo_setting['sizes'][ $size ] = $properties;
- }
+ if ( $logo_id ) {
+ $logo_setting['id'] = $logo_id;
+ $logo_setting['url'] = wp_get_attachment_url( $logo_id );
}
return $logo_setting;
@@ -651,11 +702,46 @@ abstract class SAL_Site {
return false;
}
- function get_migration_status() {
- return false;
+ function get_migration_meta() {
+ return null;
}
function get_site_segment() {
return false;
}
+
+ function get_site_creation_flow() {
+ return get_option( 'site_creation_flow' );
+ }
+
+ public function get_selected_features() {
+ return get_option( 'selected_features' );
+ }
+
+ /**
+ * Get the option storing the Anchor podcast ID that identifies a site as a podcasting site.
+ *
+ * @return string
+ */
+ public function get_anchor_podcast() {
+ return get_option( 'anchor_podcast' );
+ }
+
+ /**
+ * Check if the site is currently being built by the DIFM Lite team.
+ */
+ public function is_difm_lite_in_progress() {
+ if ( function_exists( 'has_blog_sticker' ) ) {
+ return has_blog_sticker( 'difm-lite-in-progress' );
+ }
+ return false;
+ }
+
+ /**
+ * Get the option of site intent which value is coming from the Hero Flow
+ */
+ public function get_site_intent() {
+ return get_option( 'site_intent', '' );
+ }
}
+