import ControlsGroup from "@/pages/settings/controls/ControlsGroup"; import ExternalLink from "@/common/ExternalLink"; import Notice from "@/components/Notice"; import PageContent from "@/layout/PageContent"; import Card, { CardContent, CardHeader } from "@/components/Card"; import { useSettingsStore } from "@/store/optionsStore"; import { useAppStore } from "@/store/store"; import { __ } from "@wordpress/i18n"; import Button from "@/components/Button"; import { spcApi } from "@/lib/api"; const Assets = () => { const { i18n, homeURL } = window.SPCDash; const { validPro } = useAppStore(); const { pageCacheOn, isToggleOn } = useSettingsStore(); const handleManageAssetsClick = async () => { // Save enable_assets_manager as 1 before redirecting await spcApi.updateSettings({ enable_assets_manager: 1 }); // Redirect to the assets management page window.open(homeURL + '?spc_assets=yes', '_blank'); }; const controls = { "html": [ { id: 'minify_html', type: 'toggle', label: __('Minify HTML', 'wp-cloudflare-page-cache'), description: __('Remove safe comments and extra formatting whitespace from cached HTML pages to reduce page size.', 'wp-cloudflare-page-cache'), }, ], "js": [{ id: 'cf_defer_js', type: 'toggle', label: __('Defer JavaScript', 'wp-cloudflare-page-cache'), description: <> {__('Deferring JavaScript eliminates render-blocking JS on your site and can improve load time.', 'wp-cloudflare-page-cache')} {' '} {__('More Info', 'wp-cloudflare-page-cache')} , utmCampaign: 'defer-js', locked: !validPro }, { id: 'cf_delay_js', type: 'toggle', label: __('Delay JavaScript', 'wp-cloudflare-page-cache'), description: <> {__('It makes the website faster by waiting to load JavaScript files until the user interacts with the page, like scrolling or clicking.', 'wp-cloudflare-page-cache')} {' '} {__('More Info', 'wp-cloudflare-page-cache')} , utmCampaign: 'delay-js', locked: !validPro }, { id: 'cf_delay_js_excluded_files', type: 'textarea', placeholder: 'example-1.min.js\nexample-2.min.js', label: __('Exclude JS', 'wp-cloudflare-page-cache'), description: __('Enter keywords (one per line) to be matched against external file sources or inline JavaScript content.', 'wp-cloudflare-page-cache'), utmCampaign: 'delay-js-exclusion-files', hide: !validPro || !isToggleOn('cf_delay_js'), locked: !validPro }, { id: 'cf_delay_js_excluded_paths', type: 'textarea', placeholder: '/about-us\n/blog/awesome-post', label: __('Exclude pages', 'wp-cloudflare-page-cache'), description: , utmCampaign: 'delay-js-exclusion-paths', hide: !validPro || !isToggleOn('cf_delay_js'), locked: !validPro }, ], "css": [ { id: 'unused_css', type: 'toggle', label: __('Remove Unused CSS', 'wp-cloudflare-page-cache'), description: <> {__('Make your pages load faster by keeping only the CSS that’s actually needed. The plugin automatically checks which styles are used on each page and rebuilds the cache so future visitors get a lighter, faster version.', 'wp-cloudflare-page-cache')} {' '} {__('More Info', 'wp-cloudflare-page-cache')} , utmCampaign: 'unused-css', locked: !validPro }, { id: 'unused_css_excluded_paths', type: 'textarea', placeholder: '/about-us\n/blog/awesome-post', label: __('Exclude pages', 'wp-cloudflare-page-cache'), description: , utmCampaign: 'ucss-exclusion-paths', hide: !validPro || !isToggleOn('unused_css'), locked: !validPro }, { id: 'unused_css_excluded_css', type: 'textarea', placeholder: 'example-1.min.css\nexample-2.min.css', label: __('Exclude CSS', 'wp-cloudflare-page-cache'), description: __('Add keywords (one per line) to skip certain CSS files or inline styles from being removed. Any file or CSS content that matches your keywords will be excluded from cleanup.', 'wp-cloudflare-page-cache'), utmCampaign: 'ucss-exclusion-files', hide: !validPro || !isToggleOn('unused_css'), locked: !validPro }, ], "fonts": [ { id: 'optimize_google_fonts', type: 'toggle', label: __('Optimize Google Fonts', 'wp-cloudflare-page-cache'), description: <> {__('Combine multiple Google Fonts requests, add preconnect hints, and preload the optimized font stylesheet for faster rendering.', 'wp-cloudflare-page-cache')} {' '} {__('More Info', 'wp-cloudflare-page-cache')} , }, { id: 'local_google_fonts', type: 'toggle', label: __('Local Google Fonts', 'wp-cloudflare-page-cache'), description: <> {__('Download and load Google Fonts from your server instead of Google\'s servers.', 'wp-cloudflare-page-cache')} {' '} {__('More Info', 'wp-cloudflare-page-cache')} , }, ], "assets": [ { id: 'enable_assets_manager', type: 'toggle', label: __('Enable assets manager', 'wp-cloudflare-page-cache'), description: <> {__('Control CSS & JavaScript loading based on specific contexts.', 'wp-cloudflare-page-cache')} {' '} {__('More Info', 'wp-cloudflare-page-cache')} , children: isToggleOn('enable_assets_manager') && ( ) }, ]}; return (

{__('Assets Manager', 'wp-cloudflare-page-cache')}

{__('HTML Optimizations', 'wp-cloudflare-page-cache')}

{__('Fonts Optimizations', 'wp-cloudflare-page-cache')}

{(validPro && !pageCacheOn) && ( )}

{__('JavaScript Optimizations', 'wp-cloudflare-page-cache')}

{(validPro && !pageCacheOn) && ( )}

{__('CSS Optimizations', 'wp-cloudflare-page-cache')}

) } export default Assets;