updated plugin Jetpack Protect
version 1.0.4
This commit is contained in:
@ -13,6 +13,7 @@ use Automattic\Jetpack\Connection\Client as Client;
|
||||
use Automattic\Jetpack\Connection\Initial_State as Connection_Initial_State;
|
||||
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
|
||||
use Automattic\Jetpack\Connection\Rest_Authentication as Connection_Rest_Authentication;
|
||||
use Automattic\Jetpack\JITMS\JITM as JITM;
|
||||
use Automattic\Jetpack\Licensing;
|
||||
use Automattic\Jetpack\Status as Status;
|
||||
use Automattic\Jetpack\Terms_Of_Service;
|
||||
@ -28,7 +29,7 @@ class Initializer {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const PACKAGE_VERSION = '1.8.2';
|
||||
const PACKAGE_VERSION = '2.0.3';
|
||||
|
||||
/**
|
||||
* Initialize My Jetapack
|
||||
@ -64,6 +65,9 @@ class Initializer {
|
||||
|
||||
add_action( 'load-' . $page_suffix, array( __CLASS__, 'admin_init' ) );
|
||||
|
||||
// Sets up JITMS.
|
||||
JITM::configure();
|
||||
|
||||
/**
|
||||
* Fires after the My Jetpack package is initialized
|
||||
*
|
||||
@ -80,6 +84,17 @@ class Initializer {
|
||||
* @return boolean
|
||||
*/
|
||||
public static function is_licensing_ui_enabled() {
|
||||
// Default changed to true in 1.5.0.
|
||||
$is_enabled = true;
|
||||
|
||||
/*
|
||||
* Bail if My Jetpack is not enabled,
|
||||
* and thus the licensing UI shouldn't be enabled either.
|
||||
*/
|
||||
if ( ! self::should_initialize() ) {
|
||||
$is_enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acts as a feature flag, returning a boolean for whether we should show the licensing UI.
|
||||
*
|
||||
@ -90,7 +105,7 @@ class Initializer {
|
||||
*/
|
||||
return apply_filters(
|
||||
'jetpack_my_jetpack_should_enable_add_license_screen',
|
||||
true
|
||||
$is_enabled
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -89,11 +89,26 @@ class Backup extends Hybrid_Product {
|
||||
return array(
|
||||
_x( 'Real-time cloud backups', 'Backup Product Feature', 'jetpack-my-jetpack' ),
|
||||
_x( '10GB of backup storage', 'Backup Product Feature', 'jetpack-my-jetpack' ),
|
||||
_x( '30-day archive & activity log', 'Backup Product Feature', 'jetpack-my-jetpack' ),
|
||||
_x( '30-day archive & activity log*', 'Backup Product Feature', 'jetpack-my-jetpack' ),
|
||||
_x( 'One-click restores', 'Backup Product Feature', 'jetpack-my-jetpack' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disclaimers corresponding to a feature
|
||||
*
|
||||
* @return array Backup disclaimers list
|
||||
*/
|
||||
public static function get_disclaimers() {
|
||||
return array(
|
||||
array(
|
||||
'text' => _x( '* Subject to your usage and storage limit.', 'Backup Product Disclaimer', 'jetpack-my-jetpack' ),
|
||||
'link_text' => _x( 'Learn more', 'Backup Product Disclaimer', 'jetpack-my-jetpack' ),
|
||||
'url' => Redirect::get_url( 'jetpack-faq-backup-disclaimer' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WPCOM product slug used to make the purchase
|
||||
*
|
||||
|
@ -135,9 +135,6 @@ class Extras extends Product {
|
||||
* @return null|WP_Error Null on success, WP_Error on invalid file.
|
||||
*/
|
||||
public static function activate_plugin() {
|
||||
/*
|
||||
* Silent mode True to avoid redirect
|
||||
*/
|
||||
return activate_plugin( static::get_installed_plugin_filename( 'jetpack' ), '', false, true );
|
||||
return activate_plugin( static::get_installed_plugin_filename( 'jetpack' ) );
|
||||
}
|
||||
}
|
||||
|
@ -69,11 +69,9 @@ abstract class Hybrid_Product extends Product {
|
||||
public static function activate_plugin() {
|
||||
/*
|
||||
* Activate self-installed plugin if it's installed.
|
||||
* Silent mode True to avoid redirects in Backup.
|
||||
* @TODO When new Hybrid products are added, we might not want to go silent with all of them.
|
||||
*/
|
||||
if ( parent::is_plugin_installed() ) {
|
||||
return activate_plugin( static::get_installed_plugin_filename(), '', false, true );
|
||||
return activate_plugin( static::get_installed_plugin_filename() );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -118,6 +118,7 @@ abstract class Product {
|
||||
'description' => static::get_description(),
|
||||
'long_description' => static::get_long_description(),
|
||||
'features' => static::get_features(),
|
||||
'disclaimers' => static::get_disclaimers(),
|
||||
'status' => static::get_status(),
|
||||
'pricing_for_ui' => static::get_pricing_for_ui(),
|
||||
'is_bundle' => static::is_bundle_product(),
|
||||
@ -199,6 +200,15 @@ abstract class Product {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the disclaimers corresponding to a feature
|
||||
*
|
||||
* @return ?array
|
||||
*/
|
||||
public static function get_disclaimers() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the current plan (or purchases) of the site already supports the product
|
||||
*
|
||||
|
@ -51,6 +51,13 @@ class Search extends Hybrid_Product {
|
||||
'jetpack-search-dev/jetpack-search.php',
|
||||
);
|
||||
|
||||
/**
|
||||
* Search only requires site connection
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public static $requires_user_connection = false;
|
||||
|
||||
/**
|
||||
* Get the internationalized product name
|
||||
*
|
||||
@ -153,10 +160,10 @@ class Search extends Hybrid_Product {
|
||||
|
||||
$response = wp_remote_get(
|
||||
sprintf( Constants::get_constant( 'JETPACK__WPCOM_JSON_API_BASE' ) . '/wpcom/v2/jetpack-search/pricing?record_count=%1$d&locale=%2$s', $record_count, get_user_locale() ),
|
||||
array( 'timeout' => 2 )
|
||||
array( 'timeout' => 5 )
|
||||
);
|
||||
|
||||
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
return new WP_Error( 'search_pricing_fetch_failed' );
|
||||
}
|
||||
|
||||
@ -184,12 +191,12 @@ class Search extends Hybrid_Product {
|
||||
$response = Client::wpcom_json_api_request_as_blog(
|
||||
'/sites/' . $blog_id . '/jetpack-search/plan',
|
||||
'2',
|
||||
array( 'timeout' => 2 ),
|
||||
array( 'timeout' => 5 ),
|
||||
null,
|
||||
'wpcom'
|
||||
);
|
||||
|
||||
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
return new WP_Error( 'search_state_fetch_failed' );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user