import React, { useState } from 'react'; import { __ } from '@wordpress/i18n'; import { Switch } from '../ui/switch'; import ProAlert from '../ui/pro-alert'; /** * Free stub for the CDN settings tab. * * Mirrors the rows pro renders in its own `CdnSettings` component, but every * control opens the pro upsell instead of saving. Settings.tsx only mounts this * tab while pro is missing or unlicensed — pro registers the real tab (same * `cdn` slug) through `thumbpress_settings_tabs`. */ export default function Cdn() { const [alertOpen, setAlertOpen] = useState(false); const openAlert = () => setAlertOpen(true); const isProActive = window.THUMBPRESS?.pro_active; const proBadge = ( ); const toggles = [ { label: __('Auto-offload new uploads', 'image-sizes'), description: __('Automatically upload newly added images to the CDN.', 'image-sizes'), }, { label: __('Keep local copy', 'image-sizes'), description: __('When off, the local file is deleted after upload to free disk space. The CDN copy stays.', 'image-sizes'), }, { label: __('Rewrite URLs in srcset', 'image-sizes'), description: __('Replace srcset attributes so responsive images load from the CDN too.', 'image-sizes'), }, { label: __('Rewrite WooCommerce product images', 'image-sizes'), description: __('Product, variation, and gallery images served from CDN.', 'image-sizes'), }, { label: __('Fallback to local on CDN error', 'image-sizes'), description: __('If the CDN is unreachable, serve images from your server instead of breaking the page.', 'image-sizes'), }, { label: __('Lazy load CDN images', 'image-sizes'), description: __('Apply native lazy loading to images served from the CDN.', 'image-sizes'), }, ]; const inputs = [ { label: __('Exclude file types', 'image-sizes'), description: __('Comma-separated extensions that should never offload.', 'image-sizes'), value: 'svg, pdf', }, { label: __('Exclude image sizes', 'image-sizes'), description: __('WordPress image sizes to skip. Useful if you want originals on CDN but keep thumbs local.', 'image-sizes'), value: 'thumbnail, medium', }, ]; return (
{toggles.map((row, index) => (

{row.label}

{!isProActive && proBadge}

{row.description}

))} {inputs.map((row) => (

{row.label}

{!isProActive && proBadge}

{row.description}

))}
{!isProActive && ( setAlertOpen(false)} /> )}
); }