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:
2026-03-03 12:57:35 +01:00
parent 3248cbb029
commit dec5ad7f2d
9 changed files with 1275 additions and 2884 deletions

View File

@@ -5,7 +5,7 @@ Plugin URI: https://deliciousbrains.com/wp-offload-media/
Update URI: https://deliciousbrains.com/wp-offload-media/
Description: Speed up your WordPress site by offloading your media and assets to Amazon S3, DigitalOcean Spaces or Google Cloud Storage and a CDN.
Author: Delicious Brains
Version: 3.2.12
Version: 4.0.0-cloudhost
Author URI: https://deliciousbrains.com/
Update URI: false
Network: True

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -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;
}
/**

View File

@@ -1,26 +1,9 @@
<script>
import {push} from "svelte-spa-router";
import {strings, urls} from "../js/stores";
import {licence} from "./stores";
import Header from "../components/Header.svelte";
import Button from "../components/Button.svelte";
</script>
<Header>
{#if $licence.is_set}
{#if $licence.is_valid}
<div class="licence-type">
<img src={$urls.assets + "img/icon/licence-checked.svg"} alt={$strings.licence_checked}/>
<a href={$urls.licenses} class="licence" target="_blank">{$licence.plan_plus_licence}</a>
</div>
<p>{@html $licence.customer}</p>
{:else}
<div class="licence-type">
<img src={$urls.assets + "img/icon/error.svg"} alt={$strings.licence_error}/>
<a href={$urls.licenses} class="licence" target="_blank">{$licence.status_description}</a>
</div>
{/if}
{:else}
<Button large primary on:click={() => push("/license")}>{$strings.activate_licence}</Button>
{/if}
</Header>
<div class="licence-type">
<span>Internal Build</span>
</div>
</Header>

View File

@@ -1,7 +1,6 @@
<script>
import {link} from "svelte-spa-router";
import {bucket_writable, counts, strings, urls} from "../js/stores";
import {licence, offloadRemainingWithCount, running, tools} from "./stores";
import {bucket_writable, counts, strings} from "../js/stores";
import {offloadRemainingWithCount, running, tools} from "./stores";
import Nav from "../components/Nav.svelte";
import OffloadStatus from "../components/OffloadStatus.svelte";
import ToolRunningStatus from "./ToolRunningStatus.svelte";
@@ -16,16 +15,11 @@
/**
* Get a message describing why the offload remaining button is disabled, if it is.
*
* @param {Object} licence
* @param {Object} counts
*
* @return {string}
*/
function getOffloadRemainingDisabledMessage( licence, counts ) {
if ( !licence.is_set ) {
return $strings.no_licence;
}
function getOffloadRemainingDisabledMessage( counts ) {
if ( counts.total < 1 ) {
return $strings.no_media;
}
@@ -34,19 +28,6 @@
return $strings.all_media_offloaded;
}
if (
licence.limit_info.counts_toward_limit &&
licence.limit_info.total > 0 &&
licence.limit_info.limit > 0 &&
licence.limit_info.total >= licence.limit_info.limit
) {
if ( licence.limit_info.total > licence.limit_info.limit ) {
return $strings.licence_limit_exceeded;
}
return $strings.licence_limit_reached;
}
if ( ! $bucket_writable ) {
return $strings.disabled_tool_bucket_access;
}
@@ -54,7 +35,7 @@
return "";
}
$: offloadRemainingDisabledMessage = getOffloadRemainingDisabledMessage( $licence, $counts );
$: offloadRemainingDisabledMessage = getOffloadRemainingDisabledMessage( $counts );
/**
* Close the flyout panel and kick off the offloader.
@@ -85,22 +66,6 @@
{$offloadRemainingWithCount}
</Button>
</PanelRow>
<PanelRow footer class="licence">
<div class="details">
<p class="title">{$strings.plan_usage_title}</p>
<p>{$licence.plan_usage}</p>
</div>
{#if !$licence.is_set}
<a href="/license" use:link>
{$strings.activate_licence}
</a>
{:else if $licence.limit_info.limit !== 0}
<a href={$urls.licenses} target="_blank" class="upgrade">
{$strings.upgrade_plan_cta}
</a>
{/if}
</PanelRow>
</svelte:fragment>
</OffloadStatusFlyout>
</svelte:fragment>

View File

@@ -9,10 +9,8 @@ import {
strings
} from "../js/stores";
import {pages} from "../js/routes";
import {licence} from "./stores";
import AssetsPage from "./AssetsPage.svelte";
import ToolsPage from "./ToolsPage.svelte";
import LicencePage from "./LicencePage.svelte";
import SupportPage from "./SupportPage.svelte";
import UpdateObjectACLsPromptSubPage
from "./UpdateObjectACLsPromptSubPage.svelte";
@@ -46,16 +44,6 @@ export function addPages( enabledTools ) {
component: ToolsPage
}
);
pages.add(
{
position: 90,
name: "licence",
title: () => get( strings ).licence_tab_title,
nav: true,
route: "/license",
component: LicencePage
}
);
pages.add(
{
position: 100,
@@ -117,11 +105,7 @@ export function addPages( enabledTools ) {
return false;
},
isNextRoute: ( data ) => {
if (
!get( licence ).hasOwnProperty( "is_valid" ) ||
!get( licence ).is_valid ||
!updateACLs.enabled()
) {
if ( !updateACLs.enabled() ) {
return false;
}
@@ -170,11 +154,7 @@ export function addPages( enabledTools ) {
return get( counts ).offloaded > 0 && get( current_settings ).hasOwnProperty( "bucket" ) && copyBuckets.bucket !== get( current_settings ).bucket;
},
isNextRoute: ( data ) => {
if (
!get( licence ).hasOwnProperty( "is_valid" ) ||
!get( licence ).is_valid ||
!copyBuckets.enabled()
) {
if ( !copyBuckets.enabled() ) {
return false;
}
@@ -294,8 +274,6 @@ export function addPages( enabledTools ) {
isNextRoute: ( data ) => {
// Anything to work with?
if (
!get( licence ).hasOwnProperty( "is_valid" ) ||
!get( licence ).is_valid ||
!get( current_settings ).hasOwnProperty( "bucket" ) ||
!get( counts ).hasOwnProperty( "offloaded" ) ||
get( counts ).offloaded < 1
@@ -320,8 +298,6 @@ export function addPages( enabledTools ) {
isNextRoute: ( data ) => {
// Anything to work with?
if (
!get( licence ).hasOwnProperty( "is_valid" ) ||
!get( licence ).is_valid ||
!get( current_settings ).hasOwnProperty( "bucket" ) ||
!get( counts ).hasOwnProperty( "offloaded" ) ||
get( counts ).offloaded < 1
@@ -346,8 +322,6 @@ export function addPages( enabledTools ) {
isNextRoute: ( data ) => {
// Anything to work with?
if (
!get( licence ).hasOwnProperty( "is_valid" ) ||
!get( licence ).is_valid ||
!get( current_settings ).hasOwnProperty( "bucket" ) ||
!get( counts ).hasOwnProperty( "offloaded" ) ||
get( counts ).offloaded < 1
@@ -399,8 +373,6 @@ export function addPages( enabledTools ) {
isNextRoute: ( data ) => {
// Anything to work with?
if (
!get( licence ).hasOwnProperty( "is_valid" ) ||
!get( licence ).is_valid ||
!get( current_settings ).hasOwnProperty( "bucket" ) ||
!get( counts ).hasOwnProperty( "offloaded" ) ||
get( counts ).offloaded < 1
@@ -482,8 +454,6 @@ export function addPages( enabledTools ) {
isNextRoute: ( data ) => {
// Anything to work with?
if (
!get( licence ).hasOwnProperty( "is_valid" ) ||
!get( licence ).is_valid ||
!get( current_settings ).hasOwnProperty( "bucket" ) ||
!get( counts ).hasOwnProperty( "not_offloaded" ) ||
get( counts ).not_offloaded < 1
@@ -565,8 +535,6 @@ export function addPages( enabledTools ) {
isNextRoute: ( data ) => {
// Anything to work with?
if (
!get( licence ).hasOwnProperty( "is_valid" ) ||
!get( licence ).is_valid ||
!get( current_settings ).hasOwnProperty( "bucket" ) ||
!get( counts ).hasOwnProperty( "offloaded" ) ||
get( counts ).offloaded < 1

View File

@@ -2,9 +2,8 @@ import {derived, get, writable} from "svelte/store";
import {api, config, state} from "../js/stores";
import {objectsDiffer} from "../js/objectsDiffer";
// Convenience readable store of licence, derived from config.
// We currently have one licence applied to a plugin install.
export const licence = derived( config, $config => $config.hasOwnProperty( "licences" ) ? $config.licences.at( 0 ) : [] );
// Hardcoded always-valid licence for internal build (licensing removed).
export const licence = writable( { is_set: true, is_valid: true, plan_plus_licence: 'Internal Build', customer: '', plan_usage: '', limit_info: { counts_toward_limit: false, total: 0, limit: 0 } } );
// Convenience readable store of offload remaining with count message, derived from config.
export const offloadRemainingWithCount = derived( config, $config => $config.offload_remaining_with_count );
@@ -162,20 +161,8 @@ export const assetsDefinedSettings = derived( config, $config => $config.assets_
// Convenience readable store of assets domain check info, derived from config.
export const assetsDomainCheck = derived( config, $config => $config.assets_domain_check );
// Convenience readable store indicating whether Assets functionality may be used.
export const enableAssets = derived( [licence, config], ( [$licence, $config] ) => {
if (
$licence.hasOwnProperty( "is_set" ) &&
$licence.is_set &&
$licence.hasOwnProperty( "is_valid" ) &&
$licence.is_valid &&
$config.hasOwnProperty( "assets_settings" )
) {
return true;
}
return false;
} );
// Assets functionality always enabled in internal build.
export const enableAssets = derived( config, $config => $config.hasOwnProperty( "assets_settings" ) );
/**
* Creates store of assets settings.

View File

@@ -1,5 +1,5 @@
<?php
$version = '3.2.12';
$version = '4.0.0-cloudhost';
// We set versions for both slugs to avoid undefined index errors for free slug
$GLOBALS['aws_meta']['amazon-s3-and-cloudfront-pro']['version'] = $version;