opticore/admin/settings.php

967 lines
57 KiB
PHP

<?php
/**
* Admin Settings Page with Sidebar Navigation
*/
if (!defined('ABSPATH')) {
exit;
}
// Handle form submission
if (isset($_POST['opticore_save_settings']) && check_admin_referer('opticore_settings_nonce')) {
$settings = array(
// General
'enable_cache' => isset($_POST['enable_cache']),
'enable_database_optimization' => isset($_POST['enable_database_optimization']),
'enable_gzip_compression' => isset($_POST['enable_gzip_compression']),
'disable_emojis' => isset($_POST['disable_emojis']),
'disable_dashicons' => isset($_POST['disable_dashicons']),
'disable_embeds' => isset($_POST['disable_embeds']),
'disable_xmlrpc' => isset($_POST['disable_xmlrpc']),
'disable_jquery_migrate' => isset($_POST['disable_jquery_migrate']),
'hide_wp_version' => isset($_POST['hide_wp_version']),
'remove_rsd_link' => isset($_POST['remove_rsd_link']),
'remove_shortlink' => isset($_POST['remove_shortlink']),
'disable_rss_feed' => isset($_POST['disable_rss_feed']),
'remove_rss_feed_link' => isset($_POST['remove_rss_feed_link']),
'disable_pingback' => isset($_POST['disable_pingback']),
'rest_api' => sanitize_text_field($_POST['rest_api'] ?? 'active'),
'remove_rest_api_link' => isset($_POST['remove_rest_api_link']),
'disable_google_map' => isset($_POST['disable_google_map']),
'disable_comments' => isset($_POST['disable_comments']),
'disable_author_url' => isset($_POST['disable_author_url']),
'disable_favicon' => isset($_POST['disable_favicon']),
'disable_wp_global_style' => isset($_POST['disable_wp_global_style']),
'separate_block_styles' => isset($_POST['separate_block_styles']),
'disable_heartbeat' => isset($_POST['disable_heartbeat']),
'heartbeat_frequency' => absint($_POST['heartbeat_frequency'] ?? 60),
// JavaScript
'enable_minify_js' => isset($_POST['enable_minify_js']),
'defer_javascript' => isset($_POST['defer_javascript']),
// CSS
'enable_minify_css' => isset($_POST['enable_minify_css']),
'remove_unused_css' => isset($_POST['remove_unused_css']),
'inline_critical_css' => isset($_POST['inline_critical_css']),
// Preloading
'preload_fonts' => isset($_POST['preload_fonts']),
'preload_images' => isset($_POST['preload_images']),
'dns_prefetch' => isset($_POST['dns_prefetch']),
// Lazy Loading
'enable_lazy_load' => isset($_POST['enable_lazy_load']),
'lazy_load_iframes' => isset($_POST['lazy_load_iframes']),
'lazy_load_videos' => isset($_POST['lazy_load_videos']),
// Fonts
'optimize_google_fonts' => isset($_POST['optimize_google_fonts']),
'preload_local_fonts' => isset($_POST['preload_local_fonts']),
'disable_font_awesome' => isset($_POST['disable_font_awesome']),
// CDN
'enable_cdn' => isset($_POST['enable_cdn']),
'cdn_url' => sanitize_text_field($_POST['cdn_url'] ?? ''),
// Analytics
'disable_google_analytics' => isset($_POST['disable_google_analytics']),
'local_analytics' => isset($_POST['local_analytics']),
// Code
'enable_image_optimization' => isset($_POST['enable_image_optimization']),
'remove_query_strings' => isset($_POST['remove_query_strings']),
'disable_gutenberg_blocks' => isset($_POST['disable_gutenberg_blocks']),
);
update_option('opticore_settings', $settings);
echo '<div class="notice notice-success is-dismissible"><p>' . __('Settings saved successfully!', 'opticore') . '</p></div>';
}
$settings = get_option('opticore_settings');
?>
<div class="wrap opticore-settings">
<h1>
<span class="dashicons dashicons-admin-settings"></span>
<?php _e('OptiCore Settings', 'opticore'); ?>
</h1>
<div class="opticore-settings-wrapper">
<!-- Sidebar Navigation -->
<div class="opticore-sidebar">
<nav class="opticore-tabs-nav">
<button class="opticore-tab-button active" data-tab="general">
<span class="dashicons dashicons-admin-generic"></span>
<span class="tab-label"><?php _e('General', 'opticore'); ?></span>
</button>
<button class="opticore-tab-button" data-tab="javascript">
<span class="dashicons dashicons-media-code"></span>
<span class="tab-label"><?php _e('JavaScript', 'opticore'); ?></span>
</button>
<button class="opticore-tab-button" data-tab="css">
<span class="dashicons dashicons-editor-code"></span>
<span class="tab-label"><?php _e('CSS', 'opticore'); ?></span>
</button>
<button class="opticore-tab-button" data-tab="preloading">
<span class="dashicons dashicons-performance"></span>
<span class="tab-label"><?php _e('Preloading', 'opticore'); ?></span>
</button>
<button class="opticore-tab-button" data-tab="lazyloading">
<span class="dashicons dashicons-format-image"></span>
<span class="tab-label"><?php _e('Lazy Loading', 'opticore'); ?></span>
</button>
<button class="opticore-tab-button" data-tab="fonts">
<span class="dashicons dashicons-editor-textcolor"></span>
<span class="tab-label"><?php _e('Fonts', 'opticore'); ?></span>
</button>
<button class="opticore-tab-button" data-tab="cdn">
<span class="dashicons dashicons-cloud"></span>
<span class="tab-label"><?php _e('CDN', 'opticore'); ?></span>
</button>
<button class="opticore-tab-button" data-tab="analytics">
<span class="dashicons dashicons-chart-line"></span>
<span class="tab-label"><?php _e('Analytics', 'opticore'); ?></span>
</button>
<button class="opticore-tab-button" data-tab="code">
<span class="dashicons dashicons-code-standards"></span>
<span class="tab-label"><?php _e('Code', 'opticore'); ?></span>
</button>
</nav>
</div>
<!-- Main Content -->
<div class="opticore-content">
<form method="post" action="">
<?php wp_nonce_field('opticore_settings_nonce'); ?>
<!-- General Tab -->
<div class="opticore-tab-content active" id="tab-general">
<!-- Performance Section -->
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-performance"></span>
<?php _e('Performance Optimization', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="enable_cache"><?php _e('Page Caching', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="enable_cache" name="enable_cache" value="1" <?php checked(!empty($settings['enable_cache'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Cache HTML pages to improve load times for returning visitors.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="enable_database_optimization"><?php _e('Database Optimization', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="enable_database_optimization" name="enable_database_optimization" value="1" <?php checked(!empty($settings['enable_database_optimization'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Automatically clean up post revisions, auto-drafts, and optimize database tables weekly.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="enable_gzip_compression"><?php _e('GZIP Compression', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="enable_gzip_compression" name="enable_gzip_compression" value="1" <?php checked(!empty($settings['enable_gzip_compression'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Enable GZIP compression to reduce file sizes during transfer.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
<!-- WordPress Features Section -->
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-wordpress"></span>
<?php _e('WordPress Features', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="disable_emojis"><?php _e('Disable Emojis', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_emojis" name="disable_emojis" value="1" <?php checked(!empty($settings['disable_emojis'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove emoji detection scripts and styles from WordPress.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="disable_dashicons"><?php _e('Disable Dashicons', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_dashicons" name="disable_dashicons" value="1" <?php checked(!empty($settings['disable_dashicons'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable Dashicons on frontend for non-logged-in users.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="disable_embeds"><?php _e('Disable Embeds', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_embeds" name="disable_embeds" value="1" <?php checked(!empty($settings['disable_embeds'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable WordPress oEmbed functionality and scripts.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="disable_xmlrpc"><?php _e('Disable XML-RPC', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_xmlrpc" name="disable_xmlrpc" value="1" <?php checked(!empty($settings['disable_xmlrpc'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable XML-RPC for better security (may break mobile apps).', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="disable_jquery_migrate"><?php _e('Disable jQuery Migrate', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_jquery_migrate" name="disable_jquery_migrate" value="1" <?php checked(!empty($settings['disable_jquery_migrate'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove jQuery Migrate script if not needed by your plugins.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="disable_wp_global_style"><?php _e('Disable WordPress Global Style', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_wp_global_style" name="disable_wp_global_style" value="1" <?php checked(!empty($settings['disable_wp_global_style'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove WordPress global styles if using custom theme.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="separate_block_styles"><?php _e('Separate Block Styles', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="separate_block_styles" name="separate_block_styles" value="1" <?php checked(!empty($settings['separate_block_styles'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Load block styles separately to reduce unused CSS.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
<!-- Security & Privacy Section -->
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-shield"></span>
<?php _e('Security & Privacy', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="hide_wp_version"><?php _e('Hide WordPress Version', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="hide_wp_version" name="hide_wp_version" value="1" <?php checked(!empty($settings['hide_wp_version'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove WordPress version from meta tags for better security.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="remove_rsd_link"><?php _e('Remove RSD Link', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="remove_rsd_link" name="remove_rsd_link" value="1" <?php checked(!empty($settings['remove_rsd_link'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove Really Simple Discovery link from head.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="remove_shortlink"><?php _e('Remove Shortlink Meta', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="remove_shortlink" name="remove_shortlink" value="1" <?php checked(!empty($settings['remove_shortlink'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove shortlink meta tag from head section.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
<!-- RSS & Feeds Section -->
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-rss"></span>
<?php _e('RSS & Feeds', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="disable_rss_feed"><?php _e('Disable RSS Feed', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_rss_feed" name="disable_rss_feed" value="1" <?php checked(!empty($settings['disable_rss_feed'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable RSS feeds completely if not needed.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="remove_rss_feed_link"><?php _e('Remove RSS Feed Link', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="remove_rss_feed_link" name="remove_rss_feed_link" value="1" <?php checked(!empty($settings['remove_rss_feed_link'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove RSS feed links from head section.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="disable_pingback"><?php _e('Disable Internal Pingback', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_pingback" name="disable_pingback" value="1" <?php checked(!empty($settings['disable_pingback'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable self-pingback to reduce server load.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
<!-- REST API Section -->
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-admin-plugins"></span>
<?php _e('REST API', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="rest_api"><?php _e('REST API Access', 'opticore'); ?></label>
</th>
<td>
<select id="rest_api" name="rest_api" class="regular-text">
<option value="active" <?php selected($settings['rest_api'] ?? 'active', 'active'); ?>><?php _e('Active', 'opticore'); ?></option>
<option value="admin_only" <?php selected($settings['rest_api'] ?? 'active', 'admin_only'); ?>><?php _e('Only For Administrator', 'opticore'); ?></option>
<option value="disable" <?php selected($settings['rest_api'] ?? 'active', 'disable'); ?>><?php _e('Disable', 'opticore'); ?></option>
</select>
<p class="description">
<?php _e('Control WordPress REST API access for better security.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="remove_rest_api_link"><?php _e('Remove REST API Link', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="remove_rest_api_link" name="remove_rest_api_link" value="1" <?php checked(!empty($settings['remove_rest_api_link'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove REST API link from head section.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
<!-- Third-Party Services Section -->
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-admin-site"></span>
<?php _e('Third-Party Services', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="disable_google_map"><?php _e('Disable Google Map', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_google_map" name="disable_google_map" value="1" <?php checked(!empty($settings['disable_google_map'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable Google Maps API if not used.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
<!-- Comments & Author Section -->
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-admin-comments"></span>
<?php _e('Comments & Author', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="disable_comments"><?php _e('Disable Comments', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_comments" name="disable_comments" value="1" <?php checked(!empty($settings['disable_comments'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Completely disable comments functionality.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="disable_author_url"><?php _e('Disable Author URL', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_author_url" name="disable_author_url" value="1" <?php checked(!empty($settings['disable_author_url'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove author URL field from comment forms.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
<!-- Favicon & Assets Section -->
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-format-gallery"></span>
<?php _e('Favicon & Assets', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="disable_favicon"><?php _e('Disable Favicon', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_favicon" name="disable_favicon" value="1" <?php checked(!empty($settings['disable_favicon'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable WordPress default favicon and site icon.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
<!-- Heartbeat API Section -->
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-heart"></span>
<?php _e('Heartbeat API', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="disable_heartbeat"><?php _e('Disable Heartbeat API', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_heartbeat" name="disable_heartbeat" value="1" <?php checked(!empty($settings['disable_heartbeat'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable WordPress Heartbeat API to reduce server load.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="heartbeat_frequency"><?php _e('Heartbeat Frequency (seconds)', 'opticore'); ?></label>
</th>
<td>
<input type="number" id="heartbeat_frequency" name="heartbeat_frequency" value="<?php echo esc_attr($settings['heartbeat_frequency'] ?? 60); ?>" min="15" max="120" step="15" class="small-text">
<p class="description">
<?php _e('Set Heartbeat API frequency (default: 60 seconds, range: 15-120).', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
</div>
<!-- JavaScript Tab -->
<div class="opticore-tab-content" id="tab-javascript">
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-media-code"></span>
<?php _e('JavaScript Optimization', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="enable_minify_js"><?php _e('Minify JavaScript', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="enable_minify_js" name="enable_minify_js" value="1" <?php checked(!empty($settings['enable_minify_js'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Minify JavaScript files to reduce file size and improve load times.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="defer_javascript"><?php _e('Defer JavaScript', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="defer_javascript" name="defer_javascript" value="1" <?php checked(!empty($settings['defer_javascript'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Defer non-critical JavaScript to improve initial page load time.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
</div>
<!-- CSS Tab -->
<div class="opticore-tab-content" id="tab-css">
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-editor-code"></span>
<?php _e('CSS Optimization', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="enable_minify_css"><?php _e('Minify CSS', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="enable_minify_css" name="enable_minify_css" value="1" <?php checked(!empty($settings['enable_minify_css'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Minify CSS files to reduce file size and improve load times.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="remove_unused_css"><?php _e('Remove Unused CSS', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="remove_unused_css" name="remove_unused_css" value="1" <?php checked(!empty($settings['remove_unused_css'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove unused CSS rules to reduce file size.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="inline_critical_css"><?php _e('Inline Critical CSS', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="inline_critical_css" name="inline_critical_css" value="1" <?php checked(!empty($settings['inline_critical_css'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Inline critical CSS in the HTML head for faster rendering.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
</div>
<!-- Preloading Tab -->
<div class="opticore-tab-content" id="tab-preloading">
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-performance"></span>
<?php _e('Preloading Settings', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="preload_fonts"><?php _e('Preload Fonts', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="preload_fonts" name="preload_fonts" value="1" <?php checked(!empty($settings['preload_fonts'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Preload critical fonts to improve font loading performance.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="preload_images"><?php _e('Preload Images', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="preload_images" name="preload_images" value="1" <?php checked(!empty($settings['preload_images'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Preload above-the-fold images for faster perceived loading.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="dns_prefetch"><?php _e('DNS Prefetch', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="dns_prefetch" name="dns_prefetch" value="1" <?php checked(!empty($settings['dns_prefetch'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Enable DNS prefetching for external domains to reduce latency.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
</div>
<!-- Lazy Loading Tab -->
<div class="opticore-tab-content" id="tab-lazyloading">
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-format-image"></span>
<?php _e('Lazy Loading Settings', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="enable_lazy_load"><?php _e('Lazy Load Images', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="enable_lazy_load" name="enable_lazy_load" value="1" <?php checked(!empty($settings['enable_lazy_load'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Lazy load images to improve initial page load time.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="lazy_load_iframes"><?php _e('Lazy Load Iframes', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="lazy_load_iframes" name="lazy_load_iframes" value="1" <?php checked(!empty($settings['lazy_load_iframes'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Lazy load iframes (e.g., YouTube videos, Google Maps).', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="lazy_load_videos"><?php _e('Lazy Load Videos', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="lazy_load_videos" name="lazy_load_videos" value="1" <?php checked(!empty($settings['lazy_load_videos'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Lazy load video elements to reduce initial bandwidth usage.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
</div>
<!-- Fonts Tab -->
<div class="opticore-tab-content" id="tab-fonts">
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-editor-textcolor"></span>
<?php _e('Font Optimization', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="optimize_google_fonts"><?php _e('Optimize Google Fonts', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="optimize_google_fonts" name="optimize_google_fonts" value="1" <?php checked(!empty($settings['optimize_google_fonts'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Optimize Google Fonts loading by combining requests and using font-display: swap.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="preload_local_fonts"><?php _e('Preload Local Fonts', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="preload_local_fonts" name="preload_local_fonts" value="1" <?php checked(!empty($settings['preload_local_fonts'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Preload local font files for better performance.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="disable_font_awesome"><?php _e('Disable Font Awesome', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_font_awesome" name="disable_font_awesome" value="1" <?php checked(!empty($settings['disable_font_awesome'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable Font Awesome if not used by your theme or plugins.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
</div>
<!-- CDN Tab -->
<div class="opticore-tab-content" id="tab-cdn">
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-cloud"></span>
<?php _e('CDN Settings', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="enable_cdn"><?php _e('Enable CDN', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="enable_cdn" name="enable_cdn" value="1" <?php checked(!empty($settings['enable_cdn'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Enable Content Delivery Network for static assets.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="cdn_url"><?php _e('CDN URL', 'opticore'); ?></label>
</th>
<td>
<input type="url" id="cdn_url" name="cdn_url" value="<?php echo esc_attr($settings['cdn_url'] ?? ''); ?>" class="regular-text" placeholder="https://cdn.example.com">
<p class="description">
<?php _e('Enter your CDN URL (e.g., https://cdn.example.com).', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
</div>
<!-- Analytics Tab -->
<div class="opticore-tab-content" id="tab-analytics">
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-chart-line"></span>
<?php _e('Analytics Optimization', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="disable_google_analytics"><?php _e('Disable Google Analytics', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_google_analytics" name="disable_google_analytics" value="1" <?php checked(!empty($settings['disable_google_analytics'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove Google Analytics tracking code to improve performance.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="local_analytics"><?php _e('Local Analytics', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="local_analytics" name="local_analytics" value="1" <?php checked(!empty($settings['local_analytics'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Host Google Analytics locally for better performance and GDPR compliance.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
</div>
<!-- Code Tab -->
<div class="opticore-tab-content" id="tab-code">
<div class="opticore-card">
<h2>
<span class="dashicons dashicons-code-standards"></span>
<?php _e('Code Optimization', 'opticore'); ?>
</h2>
<table class="form-table">
<tr>
<th scope="row">
<label for="enable_image_optimization"><?php _e('Image Optimization', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="enable_image_optimization" name="enable_image_optimization" value="1" <?php checked(!empty($settings['enable_image_optimization'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Optimize images, add proper dimensions, and serve WebP format when supported.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="remove_query_strings"><?php _e('Remove Query Strings', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="remove_query_strings" name="remove_query_strings" value="1" <?php checked(!empty($settings['remove_query_strings'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Remove query strings from static resources for better caching.', 'opticore'); ?>
</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="disable_gutenberg_blocks"><?php _e('Disable Gutenberg Block CSS', 'opticore'); ?></label>
</th>
<td>
<label class="opticore-switch">
<input type="checkbox" id="disable_gutenberg_blocks" name="disable_gutenberg_blocks" value="1" <?php checked(!empty($settings['disable_gutenberg_blocks'])); ?>>
<span class="opticore-slider"></span>
</label>
<p class="description">
<?php _e('Disable Gutenberg block CSS if not using block editor.', 'opticore'); ?>
</p>
</td>
</tr>
</table>
</div>
</div>
<!-- Save Button (Fixed at Bottom) -->
<div class="opticore-save-section">
<button type="submit" name="opticore_save_settings" class="button button-primary button-hero">
<span class="dashicons dashicons-saved"></span>
<?php _e('Save Settings', 'opticore'); ?>
</button>
<span class="opticore-save-info">
<span class="dashicons dashicons-info-outline"></span>
<?php _e('Changes will take effect immediately after saving.', 'opticore'); ?>
</span>
</div>
</form>
</div>
</div>
</div>