summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/sal')
-rw-r--r--plugins/jetpack/sal/class.json-api-links.php9
-rw-r--r--plugins/jetpack/sal/class.json-api-post-base.php12
-rw-r--r--plugins/jetpack/sal/class.json-api-site-base.php12
-rw-r--r--plugins/jetpack/sal/class.json-api-site-jetpack.php39
4 files changed, 52 insertions, 20 deletions
diff --git a/plugins/jetpack/sal/class.json-api-links.php b/plugins/jetpack/sal/class.json-api-links.php
index 5b18431f..21450a52 100644
--- a/plugins/jetpack/sal/class.json-api-links.php
+++ b/plugins/jetpack/sal/class.json-api-links.php
@@ -18,7 +18,7 @@ class WPCOM_JSON_API_Links {
}
// protect these methods for singleton
- protected function __construct() {
+ protected function __construct() {
$this->api = WPCOM_JSON_API::init();
}
private function __clone() { }
@@ -29,11 +29,10 @@ class WPCOM_JSON_API_Links {
*
* Used to construct meta links in API responses
*
- * @param mixed $args Optional arguments to be appended to URL
+ * @param mixed ...$args Optional arguments to be appended to URL
* @return string Endpoint URL
**/
- function get_link() {
- $args = func_get_args();
+ function get_link( ...$args ) {
$format = array_shift( $args );
$base = WPCOM_JSON_API__BASE;
@@ -127,7 +126,7 @@ class WPCOM_JSON_API_Links {
* maximum available version of /animals/%s, e.g. 1.1
*
* This method is used in get_link() to construct meta links for API responses.
- *
+ *
* @param $template_path string The generic endpoint path, e.g. /sites/%s
* @param $path string The current endpoint path, relative to the version, e.g. /sites/12345
* @param $request_method string Request method used to access the endpoint path
diff --git a/plugins/jetpack/sal/class.json-api-post-base.php b/plugins/jetpack/sal/class.json-api-post-base.php
index 4ee02cc1..50e77c19 100644
--- a/plugins/jetpack/sal/class.json-api-post-base.php
+++ b/plugins/jetpack/sal/class.json-api-post-base.php
@@ -182,9 +182,9 @@ abstract class SAL_Post {
public function get_current_user_capabilities() {
return array(
- 'publish_post' => current_user_can( 'publish_post', $this->post ),
- 'delete_post' => current_user_can( 'delete_post', $this->post ),
- 'edit_post' => current_user_can( 'edit_post', $this->post )
+ 'publish_post' => current_user_can( 'publish_post', $this->post->ID ),
+ 'delete_post' => current_user_can( 'delete_post', $this->post->ID ),
+ 'edit_post' => current_user_can( 'edit_post', $this->post->ID )
);
}
@@ -458,7 +458,7 @@ abstract class SAL_Post {
if ( 0 == $this->post->post_author )
return null;
- $show_email = $this->context === 'edit' && current_user_can( 'edit_post', $this->post );
+ $show_email = $this->context === 'edit' && current_user_can( 'edit_post', $this->post->ID );
$user = get_user_by( 'id', $this->post->post_author );
@@ -472,9 +472,9 @@ abstract class SAL_Post {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
$active_blog = get_active_blog_for_user( $user->ID );
$site_id = $active_blog->blog_id;
- $profile_URL = "http://en.gravatar.com/{$user->user_login}";
+ $profile_URL = "https://en.gravatar.com/{$user->user_login}";
} else {
- $profile_URL = 'http://en.gravatar.com/' . md5( strtolower( trim( $user->user_email ) ) );
+ $profile_URL = 'https://en.gravatar.com/' . md5( strtolower( trim( $user->user_email ) ) );
$site_id = -1;
}
diff --git a/plugins/jetpack/sal/class.json-api-site-base.php b/plugins/jetpack/sal/class.json-api-site-base.php
index 848ee90c..a124512a 100644
--- a/plugins/jetpack/sal/class.json-api-site-base.php
+++ b/plugins/jetpack/sal/class.json-api-site-base.php
@@ -51,6 +51,8 @@ abstract class SAL_Site {
abstract public function is_mapped_domain();
+ abstract public function get_unmapped_url();
+
abstract public function is_redirect();
abstract public function is_headstart_fresh();
@@ -93,6 +95,8 @@ abstract class SAL_Site {
abstract public function get_podcasting_archive();
+ abstract public function get_import_engine();
+
abstract public function get_jetpack_seo_front_page_description();
abstract public function get_jetpack_seo_title_formats();
@@ -175,7 +179,7 @@ abstract class SAL_Site {
switch ( $context ) {
case 'edit' :
- if ( ! current_user_can( 'edit_post', $post ) ) {
+ if ( ! current_user_can( 'edit_post', $post->ID ) ) {
return new WP_Error( 'unauthorized', 'User cannot edit post', 403 );
}
break;
@@ -380,7 +384,7 @@ abstract class SAL_Site {
}
function get_xmlrpc_url() {
- $xmlrpc_scheme = apply_filters( 'wpcom_json_api_xmlrpc_scheme', parse_url( get_option( 'home' ), PHP_URL_SCHEME ) );
+ $xmlrpc_scheme = apply_filters( 'wpcom_json_api_xmlrpc_scheme', wp_parse_url( get_option( 'home' ), PHP_URL_SCHEME ) );
return site_url( 'xmlrpc.php', $xmlrpc_scheme );
}
@@ -477,10 +481,6 @@ abstract class SAL_Site {
return get_admin_url();
}
- function get_unmapped_url() {
- return get_site_url( get_current_blog_id() );
- }
-
function get_theme_slug() {
return get_option( 'stylesheet' );
}
diff --git a/plugins/jetpack/sal/class.json-api-site-jetpack.php b/plugins/jetpack/sal/class.json-api-site-jetpack.php
index 0efcb3aa..b0a954ce 100644
--- a/plugins/jetpack/sal/class.json-api-site-jetpack.php
+++ b/plugins/jetpack/sal/class.json-api-site-jetpack.php
@@ -1,5 +1,7 @@
<?php
+use Automattic\Jetpack\Sync\Functions;
+
require_once dirname( __FILE__ ) . '/class.json-api-site-jetpack-base.php';
require_once dirname( __FILE__ ) . '/class.json-api-post-jetpack.php';
@@ -51,11 +53,11 @@ class Jetpack_Site extends Abstract_Jetpack_Site {
}
protected function is_version_controlled() {
- return Jetpack_Sync_Functions::is_version_controlled();
+ return Functions::is_version_controlled();
}
protected function file_system_write_access() {
- return Jetpack_Sync_Functions::file_system_write_access();
+ return Functions::file_system_write_access();
}
protected function current_theme_supports( $feature_name ) {
@@ -92,6 +94,11 @@ class Jetpack_Site extends Abstract_Jetpack_Site {
return true;
}
+ function get_unmapped_url() {
+ // Fallback to the home URL since all Jetpack sites don't have an unmapped *.wordpress.com domain.
+ return $this->get_url();
+ }
+
function is_redirect() {
return false;
}
@@ -119,7 +126,7 @@ class Jetpack_Site extends Abstract_Jetpack_Site {
function allowed_file_types() {
$allowed_file_types = array();
- // http://codex.wordpress.org/Uploading_Files
+ // https://codex.wordpress.org/Uploading_Files
$mime_types = get_allowed_mime_types();
foreach ( $mime_types as $type => $mime_type ) {
$extras = explode( '|', $type );
@@ -186,6 +193,32 @@ class Jetpack_Site extends Abstract_Jetpack_Site {
}
/**
+ * Check if full site editing should be considered as currently active. Full site editing
+ * requires the FSE plugin to be installed and activated, as well the current
+ * theme to be FSE compatible. The plugin can also be explicitly disabled via the
+ * a8c_disable_full_site_editing filter.
+ *
+ * @since 7.7.0
+ *
+ * @return bool true if full site editing is currently active.
+ */
+ function is_fse_active() {
+ if ( ! Jetpack::is_plugin_active( 'full-site-editing/full-site-editing-plugin.php' ) ) {
+ return false;
+ }
+ return function_exists( '\A8C\FSE\is_full_site_editing_active' ) && \A8C\FSE\is_full_site_editing_active();
+ }
+
+ /**
+ * Return the last engine used for an import on the site.
+ *
+ * This option is not used in Jetpack.
+ */
+ function get_import_engine() {
+ return null;
+ }
+
+ /**
* Post functions
*/