summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/sal')
-rw-r--r--plugins/jetpack/sal/class.json-api-post-base.php18
-rw-r--r--plugins/jetpack/sal/class.json-api-site-base.php56
-rw-r--r--plugins/jetpack/sal/class.json-api-site-jetpack-base.php10
-rw-r--r--plugins/jetpack/sal/class.json-api-site-jetpack.php11
4 files changed, 81 insertions, 14 deletions
diff --git a/plugins/jetpack/sal/class.json-api-post-base.php b/plugins/jetpack/sal/class.json-api-post-base.php
index 96eae901..74f7d983 100644
--- a/plugins/jetpack/sal/class.json-api-post-base.php
+++ b/plugins/jetpack/sal/class.json-api-post-base.php
@@ -1,4 +1,4 @@
-<?php
+<?php
/**
* This class wraps a WP_Post and proxies any undefined attributes
* and methods to the wrapped class. We need to do this because at present
@@ -52,7 +52,7 @@ abstract class SAL_Post {
abstract public function is_following();
abstract public function get_global_id();
abstract public function get_geo();
-
+
public function get_menu_order() {
return (int) $this->post->menu_order;
}
@@ -123,12 +123,12 @@ abstract class SAL_Post {
foreach ( (array) has_meta( $this->post->ID ) as $meta ) {
// Don't expose protected fields.
$meta_key = $meta['meta_key'];
-
+
$show = !( WPCOM_JSON_API_Metadata::is_internal_only( $meta_key ) )
&&
- (
- WPCOM_JSON_API_Metadata::is_public( $meta_key )
- ||
+ (
+ WPCOM_JSON_API_Metadata::is_public( $meta_key )
+ ||
current_user_can( 'edit_post_meta', $this->post->ID , $meta_key )
);
@@ -164,6 +164,12 @@ abstract class SAL_Post {
),
);
+ $amp_permalink = get_post_meta( $this->post->ID, '_jetpack_amp_permalink', true );
+
+ if ( ! empty( $amp_permalink ) ) {
+ $meta->links->amp = (string) $amp_permalink;
+ }
+
// add autosave link if a more recent autosave exists
if ( 'edit' === $this->context ) {
$autosave = wp_get_post_autosave( $this->post->ID );
diff --git a/plugins/jetpack/sal/class.json-api-site-base.php b/plugins/jetpack/sal/class.json-api-site-base.php
index 8e60b28f..cef41865 100644
--- a/plugins/jetpack/sal/class.json-api-site-base.php
+++ b/plugins/jetpack/sal/class.json-api-site-base.php
@@ -111,6 +111,14 @@ abstract class SAL_Site {
return false;
}
+ public function is_wpcom_store() {
+ return false;
+ }
+
+ public function woocommerce_is_active() {
+ 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' );
@@ -185,18 +193,30 @@ abstract class SAL_Site {
// copied from class.json-api-endpoints.php
public function is_post_type_allowed( $post_type ) {
// if the post type is empty, that's fine, WordPress will default to post
- if ( empty( $post_type ) )
+ if ( empty( $post_type ) ) {
return true;
+ }
// allow special 'any' type
- if ( 'any' == $post_type )
+ if ( 'any' == $post_type ) {
return true;
+ }
// check for allowed types
- if ( in_array( $post_type, $this->get_whitelisted_post_types() ) )
+ if ( in_array( $post_type, $this->get_whitelisted_post_types() ) ) {
return true;
+ }
- return false;
+ if ( $post_type_object = get_post_type_object( $post_type ) ) {
+ if ( ! empty( $post_type_object->show_in_rest ) ) {
+ return $post_type_object->show_in_rest;
+ }
+ if ( ! empty( $post_type_object->publicly_queryable ) ) {
+ return $post_type_object->publicly_queryable;
+ }
+ }
+
+ return ! empty( $post_type_object->public );
}
// copied from class.json-api-endpoints.php
@@ -299,7 +319,6 @@ abstract class SAL_Site {
'name' => $name,
'numberposts' => 1,
'post_type' => $this->get_whitelisted_post_types(),
- 'suppress_filters' => false,
) );
if ( ! $posts || ! isset( $posts[0]->ID ) || ! $posts[0]->ID ) {
@@ -559,4 +578,31 @@ abstract class SAL_Site {
function get_blog_public() {
return (int) get_option( 'blog_public' );
}
+
+ function has_pending_automated_transfer() {
+ if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
+ require_once( WP_CONTENT_DIR . '/lib/automated-transfer/utils.php' );
+ return A8C\Automated_Transfer\Utils\has_site_pending_automated_transfer( $this->blog_id );
+ }
+
+ return false;
+ }
+
+ function signup_is_store() {
+ return $this->get_design_type() === 'store';
+ }
+
+ function get_roles() {
+ return new WP_Roles();
+ }
+
+ function get_design_type() {
+ $options = get_option( 'options' );
+ return empty( $options[ 'designType'] ) ? null : $options[ 'designType' ];
+ }
+
+ function get_site_goals() {
+ $options = get_option( 'options' );
+ return empty( $options[ 'siteGoals'] ) ? null : $options[ 'siteGoals' ];
+ }
}
diff --git a/plugins/jetpack/sal/class.json-api-site-jetpack-base.php b/plugins/jetpack/sal/class.json-api-site-jetpack-base.php
index b521a10f..156fe2b0 100644
--- a/plugins/jetpack/sal/class.json-api-site-jetpack-base.php
+++ b/plugins/jetpack/sal/class.json-api-site-jetpack-base.php
@@ -1,5 +1,4 @@
<?php
-
require_once dirname( __FILE__ ) . '/class.json-api-site-base.php';
abstract class Abstract_Jetpack_Site extends SAL_Site {
@@ -30,6 +29,15 @@ abstract class Abstract_Jetpack_Site extends SAL_Site {
function before_render() {
}
+ protected function wp_memory_limit() {
+ return $this->get_constant( 'WP_MEMORY_LIMIT' );
+ }
+
+ protected function wp_max_memory_limit() {
+ return $this->get_constant( 'WP_MAX_MEMORY_LIMIT' );
+ }
+
+
function after_render( &$response ) {
// Add the updates only make them visible if the user has manage options permission and the site is the main site of the network
if ( current_user_can( 'manage_options' ) && $this->is_main_site( $response ) ) {
diff --git a/plugins/jetpack/sal/class.json-api-site-jetpack.php b/plugins/jetpack/sal/class.json-api-site-jetpack.php
index 16ab5c18..b78ac1b5 100644
--- a/plugins/jetpack/sal/class.json-api-site-jetpack.php
+++ b/plugins/jetpack/sal/class.json-api-site-jetpack.php
@@ -101,8 +101,7 @@ class Jetpack_Site extends Abstract_Jetpack_Site {
}
function has_wordads() {
- // TODO: any way to detect wordads on the site, or does it need to be modified on the way through?
- return false;
+ return Jetpack::is_module_active( 'wordads' );
}
function get_frame_nonce() {
@@ -174,6 +173,14 @@ class Jetpack_Site extends Abstract_Jetpack_Site {
return null;
}
+ function is_connected_site() {
+ return true;
+ }
+
+ function current_user_can( $role ) {
+ return current_user_can( $role );
+ }
+
/**
* Post functions
*/