WordPress Performance at Lightning Speed. Advanced optimization with Brotli compression, smart caching, and cat-like speed bursts that dash past the competition. - Brotli and Gzip compression with configurable levels - WP Rocket-inspired smart caching - Bandwidth monitoring - Automatic optimization - Performance status dashboard Includes build.sh and .distignore for WordPress-installable release ZIPs.
1291 lines
54 KiB
PHP
1291 lines
54 KiB
PHP
<?php
|
|
/**
|
|
* Admin Interface for TigerStyle Dash
|
|
* Lightning-fast WordPress performance optimization admin
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
class TigerStyle_Dash_Admin {
|
|
|
|
/**
|
|
* Plugin instance
|
|
*
|
|
* @var TigerStyle_Dash
|
|
*/
|
|
private $plugin;
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* @param TigerStyle_Dash $plugin Main plugin instance
|
|
*/
|
|
public function __construct($plugin) {
|
|
$this->plugin = $plugin;
|
|
$this->init();
|
|
}
|
|
|
|
/**
|
|
* Initialize admin functionality
|
|
*/
|
|
public function init() {
|
|
// Admin hooks
|
|
add_action('admin_post_update_dash_settings', array($this, 'handle_form_submission'));
|
|
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
|
|
add_action('admin_footer', array($this, 'render_admin_assets'));
|
|
}
|
|
|
|
/**
|
|
* Enqueue admin scripts and styles
|
|
*/
|
|
public function enqueue_admin_scripts($hook) {
|
|
if (strpos($hook, 'tigerstyle-dash') === false) {
|
|
return;
|
|
}
|
|
|
|
wp_enqueue_script(
|
|
'tigerstyle-dash-admin',
|
|
TIGERSTYLE_DASH_URL . 'assets/js/admin.js',
|
|
array('jquery'),
|
|
TIGERSTYLE_DASH_VERSION,
|
|
true
|
|
);
|
|
|
|
wp_localize_script('tigerstyle-dash-admin', 'tigerStyleDash', array(
|
|
'ajaxUrl' => admin_url('admin-ajax.php'),
|
|
'nonce' => wp_create_nonce('tigerstyle_dash_nonce'),
|
|
'strings' => array(
|
|
'analyzing' => __('Analyzing performance...', 'tigerstyle-dash'),
|
|
'clearing' => __('Clearing cache...', 'tigerstyle-dash'),
|
|
'success' => __('Success!', 'tigerstyle-dash'),
|
|
'error' => __('Error occurred', 'tigerstyle-dash')
|
|
)
|
|
));
|
|
|
|
wp_enqueue_style(
|
|
'tigerstyle-dash-admin',
|
|
TIGERSTYLE_DASH_URL . 'assets/css/admin.css',
|
|
array(),
|
|
TIGERSTYLE_DASH_VERSION
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Render main admin page
|
|
*/
|
|
public function render_main_page() {
|
|
// Check user permissions
|
|
if (!current_user_can('manage_options')) {
|
|
wp_die(__('You do not have sufficient permissions to access this page.', 'tigerstyle-dash'));
|
|
}
|
|
|
|
// Get current tab
|
|
$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'performance';
|
|
|
|
// Get current settings
|
|
$compression_enabled = get_option('tigerstyle_dash_compression_enabled', true);
|
|
$compression_method = get_option('tigerstyle_dash_compression_method', 'auto');
|
|
$compression_level = get_option('tigerstyle_dash_compression_level', 6);
|
|
$cache_enabled = get_option('tigerstyle_dash_cache_enabled', true);
|
|
$cache_ttl = get_option('tigerstyle_dash_cache_ttl', 3600);
|
|
|
|
// Get performance statistics
|
|
$stats = $this->get_performance_stats();
|
|
|
|
?>
|
|
<div class="wrap tigerstyle-dash-admin">
|
|
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
|
|
<p class="description">
|
|
<?php _e('Lightning-fast WordPress performance optimization with cat-like reflexes. Dash past the competition with advanced compression and smart caching.', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
|
|
<!-- Tab Navigation -->
|
|
<h2 class="nav-tab-wrapper">
|
|
<a href="<?php echo admin_url('admin.php?page=tigerstyle-dash&tab=performance'); ?>"
|
|
class="nav-tab <?php echo $current_tab === 'performance' ? 'nav-tab-active' : ''; ?>">
|
|
⚡ <?php _e('Performance', 'tigerstyle-dash'); ?>
|
|
</a>
|
|
<a href="<?php echo admin_url('admin.php?page=tigerstyle-dash&tab=cdn'); ?>"
|
|
class="nav-tab <?php echo $current_tab === 'cdn' ? 'nav-tab-active' : ''; ?>">
|
|
🌐 <?php _e('CDN & Edge', 'tigerstyle-dash'); ?>
|
|
</a>
|
|
<a href="<?php echo admin_url('admin.php?page=tigerstyle-dash&tab=analytics'); ?>"
|
|
class="nav-tab <?php echo $current_tab === 'analytics' ? 'nav-tab-active' : ''; ?>">
|
|
📊 <?php _e('Analytics', 'tigerstyle-dash'); ?>
|
|
</a>
|
|
</h2>
|
|
|
|
<?php
|
|
// Render the appropriate tab content
|
|
switch ($current_tab) {
|
|
case 'cdn':
|
|
$this->render_cdn_tab();
|
|
break;
|
|
case 'analytics':
|
|
$this->render_analytics_tab();
|
|
break;
|
|
case 'performance':
|
|
default:
|
|
$this->render_performance_tab($stats, $compression_enabled, $compression_method, $compression_level, $cache_enabled, $cache_ttl);
|
|
break;
|
|
}
|
|
?>
|
|
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
/**
|
|
* Render Performance tab content
|
|
*/
|
|
private function render_performance_tab($stats, $compression_enabled, $compression_method, $compression_level, $cache_enabled, $cache_ttl) {
|
|
?>
|
|
<!-- Performance Dashboard -->
|
|
<div class="dash-info-box">
|
|
<h2><?php _e('⚡ Performance Dashboard', 'tigerstyle-dash'); ?></h2>
|
|
<div class="dash-stats-grid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-top: 15px;">
|
|
<div class="stat-card">
|
|
<h3><?php _e('Compression Status', 'tigerstyle-dash'); ?></h3>
|
|
<div class="stat-value">
|
|
<?php if ($compression_enabled): ?>
|
|
<span style="color: #46b450;">✅ <?php _e('Active', 'tigerstyle-dash'); ?></span>
|
|
<?php else: ?>
|
|
<span style="color: #dc3232;">❌ <?php _e('Disabled', 'tigerstyle-dash'); ?></span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3><?php _e('Cache Status', 'tigerstyle-dash'); ?></h3>
|
|
<div class="stat-value">
|
|
<?php if ($cache_enabled): ?>
|
|
<span style="color: #46b450;">✅ <?php _e('Active', 'tigerstyle-dash'); ?></span>
|
|
<?php else: ?>
|
|
<span style="color: #dc3232;">❌ <?php _e('Disabled', 'tigerstyle-dash'); ?></span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3><?php _e('Bandwidth Saved', 'tigerstyle-dash'); ?></h3>
|
|
<div class="stat-value"><?php echo esc_html($stats['bandwidth_saved']); ?></div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3><?php _e('Files Compressed', 'tigerstyle-dash'); ?></h3>
|
|
<div class="stat-value"><?php echo esc_html($stats['files_compressed']); ?></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Settings Form -->
|
|
<div class="dash-info-box">
|
|
<h2><?php _e('🚀 Dash Settings', 'tigerstyle-dash'); ?></h2>
|
|
<form method="post" action="<?php echo admin_url('admin-post.php'); ?>">
|
|
<input type="hidden" name="action" value="update_dash_settings">
|
|
<?php wp_nonce_field('update_dash_settings', 'dash_settings_nonce'); ?>
|
|
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row"><?php _e('Enable Compression', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="compression_enabled" value="1" <?php checked($compression_enabled); ?>>
|
|
<?php _e('Enable lightning-fast compression system', 'tigerstyle-dash'); ?>
|
|
</label>
|
|
<p class="description">
|
|
<?php _e('Activate smart compression with automatic Brotli + Gzip fallbacks for maximum performance and compatibility.', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><?php _e('Compression Method', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<select name="compression_method">
|
|
<option value="auto" <?php selected($compression_method, 'auto'); ?>><?php _e('Auto (Recommended) - Brotli with Gzip fallback', 'tigerstyle-dash'); ?></option>
|
|
<option value="brotli" <?php selected($compression_method, 'brotli'); ?>><?php _e('Brotli only (Better compression)', 'tigerstyle-dash'); ?></option>
|
|
<option value="gzip" <?php selected($compression_method, 'gzip'); ?>><?php _e('Gzip only (Maximum compatibility)', 'tigerstyle-dash'); ?></option>
|
|
</select>
|
|
<p class="description">
|
|
<?php _e('Auto mode provides best performance with maximum browser compatibility. Brotli typically achieves 15-25% better compression than Gzip.', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><?php _e('Compression Level', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<input type="range" name="compression_level" min="1" max="9" value="<?php echo esc_attr($compression_level); ?>" id="compression_level">
|
|
<span id="compression_level_display"><?php echo esc_html($compression_level); ?></span>
|
|
<p class="description">
|
|
<?php _e('Higher levels provide better compression but use more CPU. Level 6 offers the best balance of speed and compression.', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><?php _e('Smart Caching', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="cache_enabled" value="1" <?php checked($cache_enabled); ?>>
|
|
<?php _e('Enable intelligent cache warming and purging', 'tigerstyle-dash'); ?>
|
|
</label>
|
|
<p class="description">
|
|
<?php _e('Automatically pre-compress popular content and clear cache when posts are updated. Reduces server load and improves response times.', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><?php _e('Cache TTL', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<input type="number" name="cache_ttl" value="<?php echo esc_attr($cache_ttl); ?>" min="300" max="86400" step="300">
|
|
<span><?php _e('seconds', 'tigerstyle-dash'); ?></span>
|
|
<p class="description">
|
|
<?php _e('How long to keep compressed files in cache. Default: 3600 seconds (1 hour).', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<?php submit_button(__('Save Dash Settings', 'tigerstyle-dash')); ?>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Cache Management -->
|
|
<div class="dash-info-box">
|
|
<h2><?php _e('🗂️ Cache Management', 'tigerstyle-dash'); ?></h2>
|
|
<p><?php _e('Manage your performance cache and analyze potential optimizations.', 'tigerstyle-dash'); ?></p>
|
|
|
|
<div style="margin-top: 15px;">
|
|
<button type="button" class="button button-secondary" id="analyze-performance">
|
|
<?php _e('Analyze Performance', 'tigerstyle-dash'); ?>
|
|
</button>
|
|
<button type="button" class="button button-secondary" id="clear-cache">
|
|
<?php _e('Clear All Cache', 'tigerstyle-dash'); ?>
|
|
</button>
|
|
<button type="button" class="button button-secondary" id="warm-cache">
|
|
<?php _e('Warm Cache', 'tigerstyle-dash'); ?>
|
|
</button>
|
|
</div>
|
|
|
|
<div id="cache-analysis-results" style="margin-top: 20px;"></div>
|
|
</div>
|
|
|
|
<!-- Dash Benefits -->
|
|
<div class="dash-info-box">
|
|
<h2><?php _e('🏃♀️ Why Dash?', 'tigerstyle-dash'); ?></h2>
|
|
<div class="dash-benefits-grid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-top: 15px;">
|
|
<div class="benefit-card">
|
|
<h3><?php _e('⚡ Lightning Speed', 'tigerstyle-dash'); ?></h3>
|
|
<p><?php _e('Dash past the competition with cat-like reflexes. Reduce file sizes by 60-80% with advanced Brotli compression.', 'tigerstyle-dash'); ?></p>
|
|
</div>
|
|
<div class="benefit-card">
|
|
<h3><?php _e('🧠 Smart Automation', 'tigerstyle-dash'); ?></h3>
|
|
<p><?php _e('Set it and forget it! Intelligent cache warming, automatic purging, and adaptive compression levels.', 'tigerstyle-dash'); ?></p>
|
|
</div>
|
|
<div class="benefit-card">
|
|
<h3><?php _e('💰 Bandwidth Savings', 'tigerstyle-dash'); ?></h3>
|
|
<p><?php _e('Lower hosting costs and faster loading for users on limited data plans or slow connections.', 'tigerstyle-dash'); ?></p>
|
|
</div>
|
|
<div class="benefit-card">
|
|
<h3><?php _e('🎯 Core Web Vitals', 'tigerstyle-dash'); ?></h3>
|
|
<p><?php _e('Improve your Google rankings with faster loading times and better Core Web Vitals scores.', 'tigerstyle-dash'); ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
/**
|
|
* Render CDN tab content
|
|
*/
|
|
private function render_cdn_tab() {
|
|
$cdn = $this->plugin->get_cdn();
|
|
$cdn_settings = $cdn->get_cdn_settings();
|
|
$cdn_analytics = $cdn->get_cdn_analytics();
|
|
$vultr_info = $cdn->get_vultr_info();
|
|
?>
|
|
<!-- CDN Status Dashboard -->
|
|
<div class="dash-info-box">
|
|
<h2><?php _e('🌐 CDN Status Dashboard', 'tigerstyle-dash'); ?></h2>
|
|
<div class="dash-stats-grid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-top: 15px;">
|
|
<div class="stat-card">
|
|
<h3><?php _e('CDN Status', 'tigerstyle-dash'); ?></h3>
|
|
<div class="stat-value">
|
|
<?php if ($cdn_analytics['enabled']): ?>
|
|
<span style="color: #46b450;">✅ <?php _e('Active', 'tigerstyle-dash'); ?></span>
|
|
<?php else: ?>
|
|
<span style="color: #dc3232;">❌ <?php _e('Disabled', 'tigerstyle-dash'); ?></span>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3><?php _e('Provider', 'tigerstyle-dash'); ?></h3>
|
|
<div class="stat-value"><?php echo esc_html(ucfirst($cdn_analytics['provider'])); ?></div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3><?php _e('Files Served', 'tigerstyle-dash'); ?></h3>
|
|
<div class="stat-value"><?php echo esc_html(number_format($cdn_analytics['files_served'])); ?></div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3><?php _e('Bandwidth Saved', 'tigerstyle-dash'); ?></h3>
|
|
<div class="stat-value"><?php echo esc_html($cdn_analytics['bandwidth_saved']); ?></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Vultr CDN Premium Showcase -->
|
|
<div class="vultr-premium-showcase dash-info-box">
|
|
<div class="vultr-header">
|
|
<div class="vultr-badge">
|
|
<span class="badge-text">RECOMMENDED</span>
|
|
<span class="badge-spark">✨</span>
|
|
</div>
|
|
<h2 class="vultr-title">
|
|
<span class="vultr-icon">🚀</span>
|
|
<?php _e('Vultr CDN - Lightning Fast Global Delivery', 'tigerstyle-dash'); ?>
|
|
</h2>
|
|
<p class="vultr-subtitle"><?php echo esc_html($vultr_info['description']); ?></p>
|
|
</div>
|
|
|
|
<!-- Performance Metrics Preview -->
|
|
<div class="vultr-metrics">
|
|
<div class="metric-card">
|
|
<div class="metric-value">99.9%</div>
|
|
<div class="metric-label">Uptime SLA</div>
|
|
</div>
|
|
<div class="metric-card">
|
|
<div class="metric-value"><50ms</div>
|
|
<div class="metric-label">Global Latency</div>
|
|
</div>
|
|
<div class="metric-card">
|
|
<div class="metric-value">24+</div>
|
|
<div class="metric-label">Edge Locations</div>
|
|
</div>
|
|
<div class="metric-card">
|
|
<div class="metric-value">$0.01</div>
|
|
<div class="metric-label">Per GB</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Benefits Grid -->
|
|
<div class="vultr-benefits-grid">
|
|
<?php foreach ($vultr_info['benefits'] as $index => $benefit): ?>
|
|
<div class="benefit-item" style="animation-delay: <?php echo $index * 0.1; ?>s;">
|
|
<div class="benefit-icon">
|
|
<?php
|
|
$icons = ['⚡', '💰', '🌍', '📊', '🔧', '💎'];
|
|
echo $icons[$index % count($icons)];
|
|
?>
|
|
</div>
|
|
<div class="benefit-text"><?php echo esc_html($benefit); ?></div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<!-- Setup Process -->
|
|
<div class="vultr-setup-process">
|
|
<h3 class="setup-title"><?php _e('Get Started in 5 Minutes', 'tigerstyle-dash'); ?></h3>
|
|
<div class="setup-steps">
|
|
<?php foreach ($vultr_info['setup_steps'] as $index => $step): ?>
|
|
<div class="setup-step">
|
|
<div class="step-number"><?php echo $index + 1; ?></div>
|
|
<div class="step-content"><?php echo wp_kses_post($step); ?></div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Call to Action -->
|
|
<div class="vultr-cta-section">
|
|
<div class="cta-content">
|
|
<h3 class="cta-headline"><?php _e('Join 1M+ Developers Using Vultr', 'tigerstyle-dash'); ?></h3>
|
|
<p class="cta-subtext"><?php _e('Start your free account today and get blazing-fast CDN performance', 'tigerstyle-dash'); ?></p>
|
|
</div>
|
|
<div class="cta-buttons">
|
|
<a href="<?php echo esc_url($vultr_info['referral_url']); ?>"
|
|
class="vultr-cta-primary"
|
|
target="_blank"
|
|
rel="noopener">
|
|
<span class="cta-icon">🚀</span>
|
|
<span class="cta-text"><?php _e('Get Vultr CDN Free', 'tigerstyle-dash'); ?></span>
|
|
<span class="cta-arrow">→</span>
|
|
</a>
|
|
<button type="button" class="vultr-cta-secondary" onclick="document.getElementById('cdn-url').focus();">
|
|
<span class="cta-icon">⚙️</span>
|
|
<span class="cta-text"><?php _e('Configure Now', 'tigerstyle-dash'); ?></span>
|
|
</button>
|
|
</div>
|
|
<p class="cta-guarantee">
|
|
<span class="guarantee-icon">🛡️</span>
|
|
<?php _e('30-day money-back guarantee • No setup fees • Cancel anytime', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- CDN Settings Form -->
|
|
<div class="dash-info-box">
|
|
<h2><?php _e('⚙️ CDN Configuration', 'tigerstyle-dash'); ?></h2>
|
|
<form method="post" action="<?php echo admin_url('admin-post.php'); ?>">
|
|
<input type="hidden" name="action" value="update_cdn_settings">
|
|
<?php wp_nonce_field('tigerstyle_dash_cdn_settings', 'tigerstyle_dash_cdn_nonce'); ?>
|
|
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row"><?php _e('Enable CDN', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="cdn_enabled" value="1" <?php checked($cdn_settings['enabled']); ?>>
|
|
<?php _e('Enable global content delivery network', 'tigerstyle-dash'); ?>
|
|
</label>
|
|
<p class="description">
|
|
<?php _e('Serve your static files from global edge locations for lightning-fast delivery worldwide.', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><?php _e('CDN Provider', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<select name="cdn_provider">
|
|
<option value="vultr" <?php selected($cdn_settings['provider'], 'vultr'); ?>><?php _e('Vultr CDN (Recommended)', 'tigerstyle-dash'); ?></option>
|
|
<option value="keycdn" <?php selected($cdn_settings['provider'], 'keycdn'); ?>><?php _e('KeyCDN', 'tigerstyle-dash'); ?></option>
|
|
<option value="maxcdn" <?php selected($cdn_settings['provider'], 'maxcdn'); ?>><?php _e('MaxCDN/StackPath', 'tigerstyle-dash'); ?></option>
|
|
<option value="cloudflare" <?php selected($cdn_settings['provider'], 'cloudflare'); ?>><?php _e('Cloudflare', 'tigerstyle-dash'); ?></option>
|
|
<option value="custom" <?php selected($cdn_settings['provider'], 'custom'); ?>><?php _e('Custom CDN', 'tigerstyle-dash'); ?></option>
|
|
</select>
|
|
<p class="description">
|
|
<?php _e('Vultr offers excellent performance and pricing with global edge locations.', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><?php _e('CDN URL', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<div class="cdn-url-input-group">
|
|
<input type="url"
|
|
name="cdn_url"
|
|
id="cdn-url"
|
|
value="<?php echo esc_attr($cdn_settings['cdn_url']); ?>"
|
|
class="regular-text cdn-url-input"
|
|
placeholder="https://your-cdn-domain.com">
|
|
<button type="button"
|
|
class="button button-secondary cdn-test-btn"
|
|
id="test-cdn-connection">
|
|
<span class="test-btn-icon">🔗</span>
|
|
<span class="test-btn-text"><?php _e('Test Connection', 'tigerstyle-dash'); ?></span>
|
|
</button>
|
|
</div>
|
|
<p class="description">
|
|
<?php _e('Your CDN distribution URL. Example: https://d123456789.vultrcdn.com', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
<div id="cdn-test-results" class="cdn-test-results"></div>
|
|
</td>
|
|
</tr>
|
|
<tr id="vultr-api-row" style="<?php echo $cdn_settings['provider'] !== 'vultr' ? 'display: none;' : ''; ?>">
|
|
<th scope="row"><?php _e('Vultr API Key', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<input type="password" name="vultr_api_key" value="<?php echo esc_attr($cdn_settings['vultr_api_key']); ?>" class="regular-text">
|
|
<p class="description">
|
|
<?php _e('Optional: API key for automatic cache purging and advanced features.', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><?php _e('File Extensions', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<input type="text" name="file_extensions" value="<?php echo esc_attr($cdn_settings['file_extensions']); ?>" class="regular-text" placeholder="pdf,zip,doc">
|
|
<p class="description">
|
|
<?php _e('Additional file extensions to serve via CDN (comma-separated). Default includes: CSS, JS, images, fonts, videos.', 'tigerstyle-dash'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row"><?php _e('Advanced Options', 'tigerstyle-dash'); ?></th>
|
|
<td>
|
|
<label>
|
|
<input type="checkbox" name="enable_for_logged_in" value="1" <?php checked($cdn_settings['enable_for_logged_in']); ?>>
|
|
<?php _e('Enable CDN for logged-in users', 'tigerstyle-dash'); ?>
|
|
</label><br>
|
|
<label>
|
|
<input type="checkbox" name="purge_on_update" value="1" <?php checked($cdn_settings['purge_on_update']); ?>>
|
|
<?php _e('Auto-purge cache when content is updated', 'tigerstyle-dash'); ?>
|
|
</label><br>
|
|
<label>
|
|
<input type="checkbox" name="test_mode" value="1" <?php checked($cdn_settings['test_mode']); ?>>
|
|
<?php _e('Test mode (verbose logging)', 'tigerstyle-dash'); ?>
|
|
</label>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<?php submit_button(__('Save CDN Settings', 'tigerstyle-dash')); ?>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- CDN Cache Management -->
|
|
<div class="dash-info-box">
|
|
<h2><?php _e('🗂️ CDN Cache Management', 'tigerstyle-dash'); ?></h2>
|
|
<p><?php _e('Manage your global CDN cache and monitor performance.', 'tigerstyle-dash'); ?></p>
|
|
|
|
<div style="margin-top: 15px;">
|
|
<button type="button" class="button button-secondary" id="purge-cdn-cache">
|
|
<?php _e('Purge CDN Cache', 'tigerstyle-dash'); ?>
|
|
</button>
|
|
<button type="button" class="button button-secondary" id="analyze-cdn-performance">
|
|
<?php _e('Analyze CDN Performance', 'tigerstyle-dash'); ?>
|
|
</button>
|
|
</div>
|
|
|
|
<div id="cdn-management-results" style="margin-top: 20px;"></div>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
/**
|
|
* Render Analytics tab content
|
|
*/
|
|
private function render_analytics_tab() {
|
|
?>
|
|
<div class="dash-info-box">
|
|
<h2><?php _e('📊 Performance Analytics', 'tigerstyle-dash'); ?></h2>
|
|
<p><?php _e('Comprehensive performance metrics and optimization insights coming soon!', 'tigerstyle-dash'); ?></p>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
/**
|
|
* Render admin styles and scripts
|
|
*/
|
|
public function render_admin_assets() {
|
|
// Only render on TigerStyle Dash admin pages
|
|
if (!isset($_GET['page']) || $_GET['page'] !== 'tigerstyle-dash') {
|
|
return;
|
|
}
|
|
?>
|
|
<style>
|
|
/* Base Styles */
|
|
.tigerstyle-dash-admin .dash-info-box {
|
|
background: #fff;
|
|
border: 1px solid #c3c4c7;
|
|
border-radius: 12px;
|
|
padding: 24px;
|
|
margin-bottom: 24px;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.tigerstyle-dash-admin .dash-info-box:hover {
|
|
box-shadow: 0 4px 16px rgba(0,0,0,0.12);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.tigerstyle-dash-admin .dash-stats-grid .stat-card,
|
|
.tigerstyle-dash-admin .dash-benefits-grid .benefit-card {
|
|
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
text-align: center;
|
|
border: 1px solid #e9ecef;
|
|
transition: all 0.3s ease;
|
|
color: #2c3e50;
|
|
}
|
|
|
|
.tigerstyle-dash-admin .dash-benefits-grid .benefit-card h3 {
|
|
color: #1a252f;
|
|
font-weight: 700;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.tigerstyle-dash-admin .dash-benefits-grid .benefit-card p {
|
|
color: #34495e;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.tigerstyle-dash-admin .stat-card:hover {
|
|
transform: translateY(-4px);
|
|
box-shadow: 0 8px 24px rgba(0,0,0,0.15);
|
|
}
|
|
|
|
.tigerstyle-dash-admin .stat-value {
|
|
font-size: 24px;
|
|
font-weight: bold;
|
|
margin-top: 8px;
|
|
background: linear-gradient(135deg, #007cba, #0073aa);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
}
|
|
|
|
/* Vultr Premium Showcase */
|
|
.vultr-premium-showcase {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
overflow: hidden;
|
|
position: relative;
|
|
}
|
|
|
|
.vultr-premium-showcase::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
|
|
pointer-events: none;
|
|
}
|
|
|
|
.vultr-header {
|
|
position: relative;
|
|
z-index: 2;
|
|
text-align: center;
|
|
margin-bottom: 32px;
|
|
}
|
|
|
|
.vultr-badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
background: rgba(255,255,255,0.2);
|
|
backdrop-filter: blur(10px);
|
|
padding: 8px 16px;
|
|
border-radius: 20px;
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
letter-spacing: 0.5px;
|
|
margin-bottom: 16px;
|
|
animation: pulse-badge 2s infinite;
|
|
}
|
|
|
|
@keyframes pulse-badge {
|
|
0%, 100% { transform: scale(1); }
|
|
50% { transform: scale(1.05); }
|
|
}
|
|
|
|
.vultr-title {
|
|
font-size: 28px;
|
|
font-weight: 700;
|
|
margin: 0 0 12px 0;
|
|
text-shadow: 0 2px 4px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
.vultr-subtitle {
|
|
font-size: 16px;
|
|
opacity: 0.9;
|
|
margin: 0;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
/* Performance Metrics */
|
|
.vultr-metrics {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
|
gap: 16px;
|
|
margin: 32px 0;
|
|
position: relative;
|
|
z-index: 2;
|
|
}
|
|
|
|
.metric-card {
|
|
background: rgba(255,255,255,0.85);
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(255,255,255,0.9);
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
text-align: center;
|
|
transition: all 0.3s ease;
|
|
color: #2c3e50;
|
|
box-shadow: 0 4px 16px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.metric-card:hover {
|
|
background: rgba(255,255,255,0.95);
|
|
transform: translateY(-4px);
|
|
box-shadow: 0 8px 24px rgba(0,0,0,0.15);
|
|
}
|
|
|
|
.metric-value {
|
|
font-size: 24px;
|
|
font-weight: 800;
|
|
margin-bottom: 4px;
|
|
color: #1a252f !important;
|
|
text-shadow: none;
|
|
}
|
|
|
|
.metric-label {
|
|
font-size: 12px;
|
|
color: #5a6c7d !important;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
text-shadow: none;
|
|
}
|
|
|
|
/* Benefits Grid */
|
|
.vultr-benefits-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
gap: 16px;
|
|
margin: 32px 0;
|
|
position: relative;
|
|
z-index: 2;
|
|
}
|
|
|
|
.benefit-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
background: rgba(255,255,255,0.15);
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(255,255,255,0.25);
|
|
border-radius: 8px;
|
|
padding: 16px;
|
|
transition: all 0.3s ease;
|
|
animation: fadeInUp 0.6s ease forwards;
|
|
opacity: 0;
|
|
transform: translateY(20px);
|
|
color: #ffffff;
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
@keyframes fadeInUp {
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
|
|
.benefit-item:hover {
|
|
background: rgba(255,255,255,0.2);
|
|
transform: translateX(4px);
|
|
}
|
|
|
|
.benefit-icon {
|
|
font-size: 20px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.benefit-text {
|
|
font-size: 14px;
|
|
line-height: 1.4;
|
|
color: #ffffff !important;
|
|
font-weight: 500;
|
|
text-shadow: 0 2px 4px rgba(0,0,0,0.6);
|
|
}
|
|
|
|
/* Setup Process */
|
|
.vultr-setup-process {
|
|
position: relative;
|
|
z-index: 2;
|
|
margin: 32px 0;
|
|
}
|
|
|
|
.setup-title {
|
|
text-align: center;
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
margin-bottom: 24px;
|
|
color: #ffffff;
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
.setup-steps {
|
|
display: grid;
|
|
gap: 16px;
|
|
max-width: 600px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.setup-step {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 16px;
|
|
background: rgba(255,255,255,0.15);
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(255,255,255,0.25);
|
|
border-radius: 8px;
|
|
padding: 16px;
|
|
transition: all 0.3s ease;
|
|
color: #ffffff;
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
.setup-step:hover {
|
|
background: rgba(255,255,255,0.15);
|
|
}
|
|
|
|
.step-number {
|
|
background: #fff;
|
|
color: #667eea;
|
|
width: 32px;
|
|
height: 32px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-weight: 700;
|
|
font-size: 14px;
|
|
flex-shrink: 0;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
|
}
|
|
|
|
.step-content {
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
padding-top: 4px;
|
|
color: #ffffff;
|
|
font-weight: 500;
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
/* Call to Action */
|
|
.vultr-cta-section {
|
|
background: rgba(255,255,255,0.15);
|
|
backdrop-filter: blur(15px);
|
|
border: 1px solid rgba(255,255,255,0.25);
|
|
border-radius: 16px;
|
|
padding: 32px;
|
|
text-align: center;
|
|
margin-top: 32px;
|
|
position: relative;
|
|
z-index: 2;
|
|
color: #ffffff;
|
|
}
|
|
|
|
.cta-headline {
|
|
font-size: 24px;
|
|
font-weight: 700;
|
|
margin-bottom: 8px;
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.3);
|
|
}
|
|
|
|
.cta-subtext {
|
|
font-size: 16px;
|
|
color: #ffffff;
|
|
font-weight: 400;
|
|
margin-bottom: 24px;
|
|
line-height: 1.5;
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.2);
|
|
}
|
|
|
|
.cta-buttons {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 16px;
|
|
justify-content: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.vultr-cta-primary {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
|
|
color: white;
|
|
text-decoration: none;
|
|
padding: 16px 32px;
|
|
border-radius: 50px;
|
|
font-weight: 700;
|
|
font-size: 16px;
|
|
box-shadow: 0 4px 16px rgba(255, 107, 53, 0.4);
|
|
transition: all 0.3s ease;
|
|
text-shadow: 0 1px 2px rgba(0,0,0,0.2);
|
|
}
|
|
|
|
.vultr-cta-primary:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 8px 24px rgba(255, 107, 53, 0.5);
|
|
color: white;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.vultr-cta-secondary {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
background: rgba(255,255,255,0.2);
|
|
backdrop-filter: blur(10px);
|
|
color: white;
|
|
border: 1px solid rgba(255,255,255,0.3);
|
|
padding: 16px 32px;
|
|
border-radius: 50px;
|
|
font-weight: 600;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.vultr-cta-secondary:hover {
|
|
background: rgba(255,255,255,0.3);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.cta-guarantee {
|
|
font-size: 13px;
|
|
opacity: 0.8;
|
|
margin: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
/* Enhanced Form Styling */
|
|
.cdn-url-input-group {
|
|
display: flex;
|
|
gap: 12px;
|
|
align-items: center;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.cdn-url-input {
|
|
flex: 1;
|
|
padding: 12px 16px;
|
|
border: 2px solid #ddd;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.cdn-url-input:focus {
|
|
border-color: #007cba;
|
|
box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
|
|
outline: none;
|
|
}
|
|
|
|
.cdn-test-btn {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 12px 20px;
|
|
background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.cdn-test-btn:hover {
|
|
background: linear-gradient(135deg, #005a87 0%, #007cba 100%);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3);
|
|
}
|
|
|
|
.cdn-test-results {
|
|
margin-top: 12px;
|
|
padding: 12px 16px;
|
|
border-radius: 8px;
|
|
border-left: 4px solid transparent;
|
|
background: #f8f9fa;
|
|
display: none;
|
|
animation: slideIn 0.3s ease;
|
|
}
|
|
|
|
@keyframes slideIn {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateY(-10px);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
|
|
.cdn-test-results.success {
|
|
background: #d4edda;
|
|
border-left-color: #28a745;
|
|
color: #155724;
|
|
}
|
|
|
|
.cdn-test-results.error {
|
|
background: #f8d7da;
|
|
border-left-color: #dc3545;
|
|
color: #721c24;
|
|
}
|
|
|
|
/* Legacy Styles */
|
|
.tigerstyle-dash-admin #compression_level {
|
|
width: 200px;
|
|
margin-right: 10px;
|
|
}
|
|
.tigerstyle-dash-admin #cache-analysis-results {
|
|
padding: 15px;
|
|
background: #f8f9fa;
|
|
border-radius: 4px;
|
|
display: none;
|
|
}
|
|
|
|
/* Responsive Design */
|
|
@media (max-width: 768px) {
|
|
.vultr-metrics {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
.vultr-benefits-grid {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.cta-buttons {
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
|
|
.vultr-cta-primary,
|
|
.vultr-cta-secondary {
|
|
width: 100%;
|
|
max-width: 280px;
|
|
justify-content: center;
|
|
}
|
|
|
|
.cdn-url-input-group {
|
|
flex-direction: column;
|
|
align-items: stretch;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
jQuery(document).ready(function($) {
|
|
// Compression level slider
|
|
$('#compression_level').on('input', function() {
|
|
$('#compression_level_display').text($(this).val());
|
|
});
|
|
|
|
// Performance analysis
|
|
$('#analyze-performance').on('click', function() {
|
|
var button = $(this);
|
|
var results = $('#cache-analysis-results');
|
|
|
|
button.prop('disabled', true).text('<?php _e('Analyzing...', 'tigerstyle-dash'); ?>');
|
|
|
|
$.post(ajaxurl, {
|
|
action: 'tigerstyle_dash_analyze',
|
|
nonce: '<?php echo wp_create_nonce('tigerstyle_dash_nonce'); ?>'
|
|
}, function(response) {
|
|
if (response.success) {
|
|
results.html('<h3>Analysis Results</h3><pre>' + JSON.stringify(response.data, null, 2) + '</pre>').show();
|
|
} else {
|
|
results.html('<p style="color: red;">Error: ' + response.data + '</p>').show();
|
|
}
|
|
}).always(function() {
|
|
button.prop('disabled', false).text('<?php _e('Analyze Performance', 'tigerstyle-dash'); ?>');
|
|
});
|
|
});
|
|
|
|
// Clear cache
|
|
$('#clear-cache').on('click', function() {
|
|
var button = $(this);
|
|
|
|
if (!confirm('<?php _e('Are you sure you want to clear all cache?', 'tigerstyle-dash'); ?>')) {
|
|
return;
|
|
}
|
|
|
|
button.prop('disabled', true).text('<?php _e('Clearing...', 'tigerstyle-dash'); ?>');
|
|
|
|
$.post(ajaxurl, {
|
|
action: 'tigerstyle_dash_clear_cache',
|
|
nonce: '<?php echo wp_create_nonce('tigerstyle_dash_nonce'); ?>'
|
|
}, function(response) {
|
|
if (response.success) {
|
|
alert(response.data.message);
|
|
} else {
|
|
alert('Error: ' + response.data);
|
|
}
|
|
}).always(function() {
|
|
button.prop('disabled', false).text('<?php _e('Clear All Cache', 'tigerstyle-dash'); ?>');
|
|
});
|
|
});
|
|
|
|
// CDN Test Connection
|
|
$('#test-cdn').on('click', function() {
|
|
var button = $(this);
|
|
var cdnUrl = $('#cdn_url').val();
|
|
|
|
if (!cdnUrl) {
|
|
alert('<?php _e('Please enter a CDN URL first.', 'tigerstyle-dash'); ?>');
|
|
return;
|
|
}
|
|
|
|
button.prop('disabled', true).html('<span class="spinner is-active" style="float: none; margin: 0 5px 0 0;"></span><?php _e('Testing...', 'tigerstyle-dash'); ?>');
|
|
|
|
$.post(ajaxurl, {
|
|
action: 'tigerstyle_test_cdn',
|
|
nonce: '<?php echo wp_create_nonce('tigerstyle_dash_ajax'); ?>',
|
|
cdn_url: cdnUrl
|
|
}, function(response) {
|
|
if (response.success) {
|
|
button.removeClass('button-secondary').addClass('button-primary');
|
|
button.html('✅ ' + response.data);
|
|
setTimeout(function() {
|
|
button.removeClass('button-primary').addClass('button-secondary').html('<?php _e('Test Connection', 'tigerstyle-dash'); ?>');
|
|
}, 3000);
|
|
} else {
|
|
button.removeClass('button-secondary').addClass('button-secondary');
|
|
button.html('❌ ' + response.data);
|
|
setTimeout(function() {
|
|
button.html('<?php _e('Test Connection', 'tigerstyle-dash'); ?>');
|
|
}, 3000);
|
|
}
|
|
}).fail(function() {
|
|
button.html('❌ <?php _e('Connection failed', 'tigerstyle-dash'); ?>');
|
|
setTimeout(function() {
|
|
button.html('<?php _e('Test Connection', 'tigerstyle-dash'); ?>');
|
|
}, 3000);
|
|
}).always(function() {
|
|
button.prop('disabled', false);
|
|
});
|
|
});
|
|
|
|
// CDN Purge Cache
|
|
$('#purge-cdn').on('click', function() {
|
|
var button = $(this);
|
|
|
|
if (!confirm('<?php _e('Are you sure you want to purge the CDN cache? This may temporarily affect site performance.', 'tigerstyle-dash'); ?>')) {
|
|
return;
|
|
}
|
|
|
|
button.prop('disabled', true).html('<span class="spinner is-active" style="float: none; margin: 0 5px 0 0;"></span><?php _e('Purging...', 'tigerstyle-dash'); ?>');
|
|
|
|
$.post(ajaxurl, {
|
|
action: 'tigerstyle_purge_cdn',
|
|
nonce: '<?php echo wp_create_nonce('tigerstyle_dash_ajax'); ?>'
|
|
}, function(response) {
|
|
if (response.success) {
|
|
button.removeClass('button-secondary').addClass('button-primary');
|
|
button.html('🔥 ' + response.data);
|
|
setTimeout(function() {
|
|
button.removeClass('button-primary').addClass('button-secondary').html('<?php _e('Purge Cache', 'tigerstyle-dash'); ?>');
|
|
}, 3000);
|
|
} else {
|
|
button.html('❌ ' + response.data);
|
|
setTimeout(function() {
|
|
button.html('<?php _e('Purge Cache', 'tigerstyle-dash'); ?>');
|
|
}, 3000);
|
|
}
|
|
}).always(function() {
|
|
button.prop('disabled', false);
|
|
});
|
|
});
|
|
|
|
// Vultr Showcase Interactions
|
|
$('.vultr-cta-primary').on('click', function(e) {
|
|
e.preventDefault();
|
|
// Add click tracking or analytics here if needed
|
|
window.open('https://supported.systems/vultr', '_blank');
|
|
});
|
|
|
|
// Benefits card hover animations
|
|
$('.benefit-card').hover(
|
|
function() {
|
|
$(this).css('transform', 'translateY(-5px)');
|
|
},
|
|
function() {
|
|
$(this).css('transform', 'translateY(0)');
|
|
}
|
|
);
|
|
|
|
// Setup step animations
|
|
$('.setup-step').each(function(index) {
|
|
var step = $(this);
|
|
setTimeout(function() {
|
|
step.addClass('animate-in');
|
|
}, index * 200);
|
|
});
|
|
|
|
// Metric cards counter animation
|
|
function animateMetrics() {
|
|
$('.metric-value').each(function() {
|
|
var $this = $(this);
|
|
var text = $this.text();
|
|
if (text.includes('%') || text.includes('.')) {
|
|
var endValue = parseFloat(text);
|
|
var isPercent = text.includes('%');
|
|
|
|
$({ countNum: 0 }).animate({ countNum: endValue }, {
|
|
duration: 2000,
|
|
easing: 'linear',
|
|
step: function() {
|
|
var display = Math.floor(this.countNum * 10) / 10;
|
|
$this.text(display + (isPercent ? '%' : ''));
|
|
},
|
|
complete: function() {
|
|
$this.text(text); // Restore original text
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
// Trigger metric animation when CDN tab is viewed
|
|
if ($('#cdn-edge-tab').hasClass('nav-tab-active')) {
|
|
setTimeout(animateMetrics, 500);
|
|
}
|
|
|
|
// Tab switching detection for animations
|
|
$('.nav-tab').on('click', function() {
|
|
if ($(this).attr('href') === '#cdn-edge-tab') {
|
|
setTimeout(animateMetrics, 500);
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
|
|
/**
|
|
* Get performance statistics
|
|
*/
|
|
private function get_performance_stats() {
|
|
// Get basic stats - in a real implementation, these would be calculated from actual data
|
|
return array(
|
|
'bandwidth_saved' => $this->format_bytes(get_option('tigerstyle_dash_bandwidth_saved', 0)),
|
|
'files_compressed' => number_format(get_option('tigerstyle_dash_files_compressed', 0)),
|
|
'avg_compression_ratio' => get_option('tigerstyle_dash_avg_compression_ratio', 0) . '%',
|
|
'cache_hit_ratio' => get_option('tigerstyle_dash_cache_hit_ratio', 0) . '%'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Format bytes into human readable format
|
|
*/
|
|
private function format_bytes($bytes, $precision = 2) {
|
|
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
|
|
|
for ($i = 0; $bytes > 1024 && $i < count($units) - 1; $i++) {
|
|
$bytes /= 1024;
|
|
}
|
|
|
|
return round($bytes, $precision) . ' ' . $units[$i];
|
|
}
|
|
|
|
/**
|
|
* Handle form submission
|
|
*/
|
|
public function handle_form_submission() {
|
|
// Verify nonce
|
|
if (!wp_verify_nonce($_POST['dash_settings_nonce'], 'update_dash_settings')) {
|
|
wp_die(__('Security check failed.', 'tigerstyle-dash'));
|
|
}
|
|
|
|
// Check user permissions
|
|
if (!current_user_can('manage_options')) {
|
|
wp_die(__('You do not have sufficient permissions.', 'tigerstyle-dash'));
|
|
}
|
|
|
|
// Update settings
|
|
update_option('tigerstyle_dash_compression_enabled', isset($_POST['compression_enabled']));
|
|
update_option('tigerstyle_dash_compression_method', sanitize_text_field($_POST['compression_method']));
|
|
update_option('tigerstyle_dash_compression_level', intval($_POST['compression_level']));
|
|
update_option('tigerstyle_dash_cache_enabled', isset($_POST['cache_enabled']));
|
|
update_option('tigerstyle_dash_cache_ttl', intval($_POST['cache_ttl']));
|
|
|
|
// Redirect back with success message
|
|
wp_redirect(add_query_arg(array(
|
|
'page' => 'tigerstyle-dash',
|
|
'message' => 'settings_updated'
|
|
), admin_url('admin.php')));
|
|
exit;
|
|
}
|
|
}
|