feat: remove licensing system and bump version to 4.0.0-cloudhost
- Remove AS3CF_Pro_Licences_Updates instantiation and all $this->licence references from the PHP backend; stub methods return safe defaults (is_valid_licence → true, is_licence_over_media_limit → false, feature_enabled → true, is_pro_plugin_setup bypasses licence check) - Remove Licences REST API endpoint from add_api_endpoints() - Remove 'licence' from allowed settings keys - Bump version from 3.2.12 to 4.0.0-cloudhost in version.php and plugin header - Replace licence derived store with hardcoded always-valid writable store - Simplify enableAssets store to depend only on config.assets_settings - Remove licence panel row from Nav flyout; remove licence check from offload remaining button disabled logic - Replace Header licence display with "Internal Build" label - Remove LicencePage route registration from pages.js; drop licence import and is_valid guards from all isNextRoute functions - Rebuild compiled Svelte bundle Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,6 @@ use DeliciousBrains\WP_Offload_Media\API\V1\Settings;
|
||||
use DeliciousBrains\WP_Offload_Media\API\V1\State;
|
||||
use DeliciousBrains\WP_Offload_Media\Items\Item;
|
||||
use DeliciousBrains\WP_Offload_Media\Items\Item_Handler;
|
||||
use DeliciousBrains\WP_Offload_Media\Pro\API\V1\Licences;
|
||||
use DeliciousBrains\WP_Offload_Media\Pro\API\V1\Tools;
|
||||
use DeliciousBrains\WP_Offload_Media\Pro\Integrations\Assets\Assets as Assets_Integration;
|
||||
use DeliciousBrains\WP_Offload_Media\Pro\Integrations\BuddyBoss\BuddyBoss;
|
||||
@@ -40,11 +39,6 @@ use DeliciousBrains\WP_Offload_Media\Providers\Storage\Storage_Provider;
|
||||
|
||||
class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
|
||||
/**
|
||||
* @var AS3CF_Pro_Licences_Updates
|
||||
*/
|
||||
protected $licence;
|
||||
|
||||
/**
|
||||
* @var Tools_Manager
|
||||
*/
|
||||
@@ -82,11 +76,6 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
$this->plugin_title = __( 'WP Offload Media', 'amazon-s3-and-cloudfront' );
|
||||
$this->plugin_menu_title = __( 'WP Offload Media', 'amazon-s3-and-cloudfront' );
|
||||
|
||||
// Licence and updates handler
|
||||
if ( is_admin() || is_network_admin() || AS3CF_Utils::is_rest_api() || ( defined( 'WP_CLI' ) && class_exists( 'WP_CLI' ) ) ) {
|
||||
$this->licence = new AS3CF_Pro_Licences_Updates( $this );
|
||||
}
|
||||
|
||||
// add our custom CSS classes to <body>
|
||||
add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
|
||||
|
||||
@@ -168,8 +157,7 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
*/
|
||||
public function add_api_endpoints( array $api_endpoints ): array {
|
||||
return array_merge( $api_endpoints, array(
|
||||
Licences::name() => new Licences( $this ),
|
||||
Tools::name() => new Tools( $this ),
|
||||
Tools::name() => new Tools( $this ),
|
||||
) );
|
||||
}
|
||||
|
||||
@@ -284,10 +272,7 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return array
|
||||
*/
|
||||
public function get_allowed_settings_keys( bool $include_legacy = false ): array {
|
||||
return array_merge(
|
||||
parent::get_allowed_settings_keys( $include_legacy ),
|
||||
array( 'licence' )
|
||||
);
|
||||
return parent::get_allowed_settings_keys( $include_legacy );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,7 +389,7 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return string
|
||||
*/
|
||||
public function get_plugin_row_slug() {
|
||||
return sanitize_title( $this->licence->plugin->name );
|
||||
return 'amazon-s3-and-cloudfront-pro';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -418,7 +403,7 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return bool
|
||||
*/
|
||||
public function is_valid_licence( $skip_transient_check = false, $skip_expired_check = true, $licence_response = array() ) {
|
||||
return $this->licence->is_valid_licence( $skip_transient_check, $skip_expired_check, $licence_response );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -429,14 +414,14 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return bool
|
||||
*/
|
||||
public function is_licence_over_media_limit( $media_limit_response = array() ) {
|
||||
return $this->licence->is_licence_over_media_limit( $media_limit_response );
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the API with the total of attachments offloaded to S3 for the site
|
||||
*/
|
||||
public function update_media_library_total() {
|
||||
$this->licence->check_licence_media_limit( true, true );
|
||||
// No-op: licensing removed.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,34 +431,10 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return array
|
||||
*/
|
||||
public function get_total_and_limit_for_licence(): array {
|
||||
$cached_media_limit_check = get_site_transient( $this->licence->plugin->prefix . '_licence_media_check' );
|
||||
|
||||
$media_limit_check = [];
|
||||
$media_limit_check['limit'] = 0;
|
||||
$media_limit_check['total'] = 0;
|
||||
if (
|
||||
! is_array( $media_limit_check ) ||
|
||||
! isset( $media_limit_check['total'] ) ||
|
||||
! isset( $media_limit_check['limit'] )
|
||||
) {
|
||||
// Can't use latest API call.
|
||||
if (
|
||||
! is_array( $cached_media_limit_check ) ||
|
||||
! isset( $cached_media_limit_check['total'] ) ||
|
||||
! isset( $cached_media_limit_check['limit'] )
|
||||
) {
|
||||
// Cached data failed
|
||||
return array();
|
||||
}
|
||||
|
||||
// Use cached data
|
||||
$media_limit_check = $cached_media_limit_check;
|
||||
}
|
||||
|
||||
return array(
|
||||
'total' => absint( $media_limit_check['total'] ),
|
||||
'limit' => absint( $media_limit_check['limit'] ),
|
||||
'counts_toward_limit' => $this->licence->counts_toward_limit( $media_limit_check ),
|
||||
'total' => 0,
|
||||
'limit' => 0,
|
||||
'counts_toward_limit' => false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -515,7 +476,7 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return array
|
||||
*/
|
||||
public function get_plugin_addons() {
|
||||
return $this->licence->addons;
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -530,33 +491,6 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
return $this->_is_pro_plugin_setup[ $with_credentials ];
|
||||
}
|
||||
|
||||
if ( isset( $this->licence ) ) {
|
||||
// If no license set, then Pro isn't set up.
|
||||
if ( empty( $this->licence->get_licence_key() ) ) {
|
||||
$this->_is_pro_plugin_setup[ $with_credentials ] = false;
|
||||
|
||||
// Ensure notice regarding license response issues is removed if there is no license.
|
||||
$this->notices->remove_notice_by_id( 'as3cfpro-licence-response-missing' );
|
||||
|
||||
return $this->_is_pro_plugin_setup[ $with_credentials ];
|
||||
}
|
||||
|
||||
// If there hasn't yet been a check of the licence, or it is not valid, Pro setup is not complete.
|
||||
$licence_response = json_decode( get_site_transient( $this->licence->plugin->prefix . '_licence_response' ), true );
|
||||
|
||||
// Ensure notice regarding license response issues is removed if things look ok.
|
||||
$this->notices->remove_notice_by_id( 'as3cfpro-licence-response-missing' );
|
||||
|
||||
// If licence is looking good, then we're only concerned if licence is over limit.
|
||||
$media_limit_response = get_site_transient( $this->licence->plugin->prefix . '_licence_media_check' );
|
||||
if ( ! empty( $media_limit_response ) && is_array( $media_limit_response ) && $this->is_licence_over_media_limit( $media_limit_response ) ) {
|
||||
// License key over the media library total license limit
|
||||
$this->_is_pro_plugin_setup[ $with_credentials ] = false;
|
||||
|
||||
return $this->_is_pro_plugin_setup[ $with_credentials ];
|
||||
}
|
||||
}
|
||||
|
||||
$this->_is_pro_plugin_setup[ $with_credentials ] = $this->is_plugin_setup( $with_credentials );
|
||||
|
||||
return $this->_is_pro_plugin_setup[ $with_credentials ];
|
||||
@@ -575,13 +509,7 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
$output .= number_format_i18n( $post_count );
|
||||
$output .= "\r\n\r\n";
|
||||
|
||||
$output .= 'Pro Upgrade: ';
|
||||
$output .= "\r\n";
|
||||
$output .= 'License Status: ';
|
||||
$output .= $this->licence->licence_status_description();
|
||||
$output .= "\r\n";
|
||||
$output .= 'License Constant: ';
|
||||
$output .= $this->licence->is_licence_constant() ? 'On' : 'Off';
|
||||
$output .= 'Pro Upgrade: Internal Build (licensing removed)';
|
||||
$output .= "\r\n\r\n";
|
||||
|
||||
$output .= 'Host IP: ';
|
||||
@@ -814,12 +742,7 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return array
|
||||
*/
|
||||
public function get_licences( bool $skip_transient_check = false ): array {
|
||||
if ( empty( $this->licence ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// We currently have one licence applied to a plugin install.
|
||||
return array( $this->licence->get_licence_info( $skip_transient_check ) );
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -828,7 +751,7 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return bool
|
||||
*/
|
||||
public function is_licence_constant() {
|
||||
return $this->licence->is_licence_constant();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -839,14 +762,14 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
public function activate_licence( $licence_key ) {
|
||||
return $this->licence->activate( $licence_key );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the license.
|
||||
*/
|
||||
public function remove_licence() {
|
||||
$this->licence->remove();
|
||||
// No-op: licensing removed.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -855,17 +778,6 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return array[]
|
||||
*/
|
||||
private function get_documentation() {
|
||||
$response = get_site_transient( $this->licence->plugin->prefix . '_licence_response' );
|
||||
|
||||
if ( $response ) {
|
||||
$decoded = json_decode( $response, true );
|
||||
|
||||
if ( ! empty( $decoded['documentation'] ) && is_array( $decoded['documentation'] ) ) {
|
||||
return $decoded['documentation'];
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to hard-coded docs.
|
||||
return array(
|
||||
array(
|
||||
'title' => __( 'Getting Started', 'amazon-s3-and-cloudfront' ),
|
||||
@@ -959,38 +871,7 @@ class Amazon_S3_And_CloudFront_Pro extends Amazon_S3_And_CloudFront {
|
||||
* @return bool
|
||||
*/
|
||||
public function feature_enabled( string $feature ): bool {
|
||||
$licences = $this->get_licences();
|
||||
|
||||
// Fall-back to transient if licence property not yet initialized.
|
||||
if ( empty( $licences ) ) {
|
||||
$decoded_licence = json_decode( get_site_transient( 'as3cfpro_licence_response' ), true );
|
||||
$licences = empty( $decoded_licence ) ? array() : array( $decoded_licence );
|
||||
}
|
||||
|
||||
if ( empty( $licences ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $licences as $licence ) {
|
||||
// TODO: >>> Remove when https://github.com/deliciousbrains/site/issues/3287 implemented.
|
||||
if ( empty( $licence['features'] ) && ! empty( $licence['plan'] ) && ! in_array( $licence['plan'], array( 'Bronze', 'Silver' ) ) ) {
|
||||
$licence['features'][] = 'assets';
|
||||
}
|
||||
if ( empty( $licence['features'] ) && ! empty( $licence['licence_name'] ) && ! in_array( $licence['licence_name'], array( 'Bronze', 'Silver' ) ) ) {
|
||||
$licence['features'][] = 'assets';
|
||||
}
|
||||
// TODO: <<< Remove when https://github.com/deliciousbrains/site/issues/3287 implemented.
|
||||
|
||||
if ( empty( $licence['features'] ) || ! is_array( $licence['features'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( in_array( $feature, $licence['features'] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user