summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2017-01-03 19:27:21 -0500
committerAnthony G. Basile <blueness@gentoo.org>2017-01-03 19:27:21 -0500
commit8f0ed12d83c648763b1c538698bfa0b3005a88c3 (patch)
tree130ecb4629dc8a6f8563d93f0c01d12d7f7cccc8 /plugins/jetpack/_inc/lib
parentUpdate plugin jetpack to 4.4.1 (diff)
downloadblogs-gentoo-8f0ed12d83c648763b1c538698bfa0b3005a88c3.tar.gz
blogs-gentoo-8f0ed12d83c648763b1c538698bfa0b3005a88c3.tar.bz2
blogs-gentoo-8f0ed12d83c648763b1c538698bfa0b3005a88c3.zip
Update plugin jetpack to 4.4.2
Diffstat (limited to 'plugins/jetpack/_inc/lib')
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php32
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php4
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-settings-page.php28
-rw-r--r--plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php28
4 files changed, 53 insertions, 39 deletions
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php
index bfb45938..f37c5bd8 100644
--- a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php
@@ -41,10 +41,6 @@ abstract class Jetpack_Admin_Page {
self::$block_page_rendering_for_idc = (
Jetpack::validate_sync_error_idc_option() && ! Jetpack_Options::get_option( 'safe_mode_confirmed' )
);
-
- if ( ! self::$block_page_rendering_for_idc ) {
- add_action( 'admin_enqueue_scripts', array( $this, 'additional_styles' ) );
- }
}
function add_actions() {
@@ -71,6 +67,10 @@ abstract class Jetpack_Admin_Page {
add_action( "admin_print_styles-$hook", array( $this, 'admin_styles' ) );
add_action( "admin_print_scripts-$hook", array( $this, 'admin_scripts' ) );
+ if ( ! self::$block_page_rendering_for_idc ) {
+ add_action( "admin_print_styles-$hook", array( $this, 'additional_styles' ) );
+ }
+
// Check if the site plan changed and deactivate modules accordingly.
add_action( 'current_screen', array( $this, 'check_plan_deactivate_modules' ) );
@@ -136,12 +136,36 @@ abstract class Jetpack_Admin_Page {
wp_style_add_data( 'jetpack-admin', 'suffix', $min );
}
+ /**
+ * Checks if WordPress version is too old to have REST API.
+ *
+ * @since 4.3
+ *
+ * @return bool
+ */
function is_wp_version_too_old() {
global $wp_version;
return ( ! function_exists( 'rest_api_init' ) || version_compare( $wp_version, '4.4-z', '<=' ) );
}
/**
+ * Checks if REST API is enabled.
+ *
+ * @since 4.4.2
+ *
+ * @return bool
+ */
+ function is_rest_api_enabled() {
+ return
+ /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
+ apply_filters( 'rest_enabled', true ) &&
+ /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
+ apply_filters( 'rest_jsonp_enabled', true ) &&
+ /** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
+ apply_filters( 'rest_authentication_errors', true );
+ }
+
+ /**
* Checks the site plan and deactivates modules that were active but are no longer included in the plan.
*
* @since 4.4.0
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php
index eeec3c2a..1d1ac0bb 100644
--- a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-react-page.php
@@ -27,8 +27,8 @@ class Jetpack_React_Page extends Jetpack_Admin_Page {
return; // No need to handle the fallback redirection if we are not on the Jetpack page
}
- // Adding a redirect meta tag for older WordPress versions
- if ( $this->is_wp_version_too_old() ) {
+ // Adding a redirect meta tag for older WordPress versions or if the REST API is disabled
+ if ( $this->is_wp_version_too_old() || ! $this->is_rest_api_enabled() ) {
$this->is_redirecting = true;
add_action( 'admin_head', array( $this, 'add_fallback_head_meta' ) );
}
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-settings-page.php b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-settings-page.php
index 1f3dd3ef..dd9b5ea1 100644
--- a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-settings-page.php
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-settings-page.php
@@ -30,39 +30,50 @@ class Jetpack_Settings_Page extends Jetpack_Admin_Page {
// We have static.html so let's continue trying to fetch the others
$noscript_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-noscript-notice.html' );
- $version_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-version-notice.html' );
+ $version_notice = $rest_api_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-version-notice.html' );
$ie_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-ie-notice.html' );
$noscript_notice = str_replace(
'#HEADER_TEXT#',
- esc_html( __( 'You have JavaScript disabled', 'jetpack' ) ),
+ esc_html__( 'You have JavaScript disabled', 'jetpack' ),
$noscript_notice
);
$noscript_notice = str_replace(
'#TEXT#',
- esc_html( __( "Turn on JavaScript to unlock Jetpack's full potential!", 'jetpack' ) ),
+ esc_html__( "Turn on JavaScript to unlock Jetpack's full potential!", 'jetpack' ),
$noscript_notice
);
$version_notice = str_replace(
'#HEADER_TEXT#',
- esc_html( __( 'You are using an outdated version of WordPress', 'jetpack' ) ),
+ esc_html__( 'You are using an outdated version of WordPress', 'jetpack' ),
$version_notice
);
$version_notice = str_replace(
'#TEXT#',
- esc_html( __( "Update WordPress to unlock Jetpack's full potential!", 'jetpack' ) ),
+ esc_html__( "Update WordPress to unlock Jetpack's full potential!", 'jetpack' ),
$version_notice
);
+ $rest_api_notice = str_replace(
+ '#HEADER_TEXT#',
+ esc_html( __( 'WordPress REST API is disabled', 'jetpack' ) ),
+ $rest_api_notice
+ );
+ $rest_api_notice = str_replace(
+ '#TEXT#',
+ esc_html( __( "Enable WordPress REST API to unlock Jetpack's full potential!", 'jetpack' ) ),
+ $rest_api_notice
+ );
+
$ie_notice = str_replace(
'#HEADER_TEXT#',
- esc_html( __( 'You are using an unsupported browser version.', 'jetpack' ) ),
+ esc_html__( 'You are using an unsupported browser version.', 'jetpack' ),
$ie_notice
);
$ie_notice = str_replace(
'#TEXT#',
- esc_html( __( "Update your browser to unlock Jetpack's full potential!", 'jetpack' ) ),
+ esc_html__( "Update your browser to unlock Jetpack's full potential!", 'jetpack' ),
$ie_notice
);
@@ -73,6 +84,9 @@ class Jetpack_Settings_Page extends Jetpack_Admin_Page {
if ( $this->is_wp_version_too_old() ) {
echo $version_notice;
}
+ if ( ! $this->is_rest_api_enabled() ) {
+ echo $rest_api_notice;
+ }
echo $noscript_notice;
echo $ie_notice;
?>
diff --git a/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php b/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php
index d14ce4cf..59980b22 100644
--- a/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php
+++ b/plugins/jetpack/_inc/lib/core-api/class.jetpack-core-api-module-endpoints.php
@@ -7,19 +7,6 @@ class Jetpack_Core_API_Module_Toggle_Endpoint
extends Jetpack_Core_API_XMLRPC_Consumer_Endpoint {
/**
- * List of modules that require WPCOM public access.
- *
- * @since 4.3.0
- *
- * @var array
- */
- private $modules_requiring_public = array(
- 'photon',
- 'enhanced-distribution',
- 'json-api',
- );
-
- /**
* Check if the module requires the site to be publicly accessible from WPCOM.
* If the site meets this requirement, the module is activated. Otherwise an error is returned.
*
@@ -68,17 +55,6 @@ class Jetpack_Core_API_Module_Toggle_Endpoint
);
}
- if (
- in_array( $module_slug, $this->modules_requiring_public )
- && ! $this->is_site_public()
- ) {
- return new WP_Error(
- 'rest_cannot_publish',
- esc_html__( 'This module requires your site to be set to publicly accessible.', 'jetpack' ),
- array( 'status' => 424 )
- );
- }
-
if ( Jetpack::activate_module( $module_slug, false, false ) ) {
return rest_ensure_response( array(
'code' => 'success',
@@ -1093,9 +1069,9 @@ class Jetpack_Core_API_Module_Data_Endpoint {
}
$data = json_decode( base64_decode( $vaultpress->contact_service( 'plugin_data' ) ) );
- if ( is_wp_error( $data ) ) {
+ if ( is_wp_error( $data ) || ! isset( $data->backups->last_backup ) ) {
return $data;
- } else if ( ! $data->backups->last_backup ) {
+ } else if ( empty( $data->backups->last_backup ) ) {
return rest_ensure_response( array(
'code' => 'success',
'message' => esc_html__( 'VaultPress is active and will back up your site soon.', 'jetpack' ),