264 lines
11 KiB
PHP
264 lines
11 KiB
PHP
<?php
|
|
/**
|
|
* Advanced Settings Tab
|
|
*
|
|
* @package Instagram_Gallery_Sync_Pro
|
|
*/
|
|
|
|
// Prevent direct access
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
$logger = new IGSP_Logger();
|
|
$logs = $logger->get_formatted_logs(50);
|
|
$image_handler = new IGSP_Image_Handler();
|
|
?>
|
|
|
|
<form method="post" action="options.php" class="igsp-settings-form" id="igsp-advanced-form">
|
|
<?php settings_fields('igsp_advanced_settings'); ?>
|
|
|
|
<div class="igsp-section">
|
|
<h2>
|
|
<?php esc_html_e('Debug & Development', 'instagram-gallery-sync-pro'); ?>
|
|
</h2>
|
|
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row">
|
|
<?php esc_html_e('Debug Mode', 'instagram-gallery-sync-pro'); ?>
|
|
</th>
|
|
<td>
|
|
<?php $debug = get_option('igsp_debug_mode', 'no'); ?>
|
|
<fieldset>
|
|
<label>
|
|
<input type="radio" name="igsp_debug_mode" value="yes" <?php checked($debug, 'yes'); ?>>
|
|
<?php esc_html_e('Enabled', 'instagram-gallery-sync-pro'); ?>
|
|
</label>
|
|
<label>
|
|
<input type="radio" name="igsp_debug_mode" value="no" <?php checked($debug, 'no'); ?>>
|
|
<?php esc_html_e('Disabled', 'instagram-gallery-sync-pro'); ?>
|
|
</label>
|
|
</fieldset>
|
|
<p class="description">
|
|
<?php esc_html_e('Enable to log all sync activities. Disable in production for better performance.', 'instagram-gallery-sync-pro'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="igsp-section">
|
|
<h2>
|
|
<?php esc_html_e('Performance', 'instagram-gallery-sync-pro'); ?>
|
|
</h2>
|
|
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="igsp_cache_duration">
|
|
<?php esc_html_e('Cache Duration', 'instagram-gallery-sync-pro'); ?>
|
|
</label>
|
|
</th>
|
|
<td>
|
|
<?php $cache = get_option('igsp_cache_duration', 3600); ?>
|
|
<select id="igsp_cache_duration" name="igsp_cache_duration">
|
|
<option value="3600" <?php selected($cache, 3600); ?>>
|
|
<?php esc_html_e('1 Hour', 'instagram-gallery-sync-pro'); ?>
|
|
</option>
|
|
<option value="21600" <?php selected($cache, 21600); ?>>
|
|
<?php esc_html_e('6 Hours', 'instagram-gallery-sync-pro'); ?>
|
|
</option>
|
|
<option value="43200" <?php selected($cache, 43200); ?>>
|
|
<?php esc_html_e('12 Hours', 'instagram-gallery-sync-pro'); ?>
|
|
</option>
|
|
<option value="86400" <?php selected($cache, 86400); ?>>
|
|
<?php esc_html_e('24 Hours', 'instagram-gallery-sync-pro'); ?>
|
|
</option>
|
|
</select>
|
|
<p class="description">
|
|
<?php esc_html_e('How long to cache the gallery HTML.', 'instagram-gallery-sync-pro'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row">
|
|
<?php esc_html_e('Request Timeout', 'instagram-gallery-sync-pro'); ?>
|
|
</th>
|
|
<td>
|
|
<div class="igsp-slider-wrapper">
|
|
<input type="range" id="igsp_request_timeout" name="igsp_request_timeout" min="10" max="60"
|
|
value="<?php echo esc_attr(get_option('igsp_request_timeout', 30)); ?>">
|
|
<span class="igsp-slider-value">
|
|
<?php echo esc_html(get_option('igsp_request_timeout', 30)); ?>s
|
|
</span>
|
|
</div>
|
|
<p class="description">
|
|
<?php esc_html_e('Timeout for Instagram requests in seconds.', 'instagram-gallery-sync-pro'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row">
|
|
<?php esc_html_e('Auto-Delete Old Posts', 'instagram-gallery-sync-pro'); ?>
|
|
</th>
|
|
<td>
|
|
<div class="igsp-slider-wrapper">
|
|
<input type="range" id="igsp_auto_delete_days" name="igsp_auto_delete_days" min="0" max="365"
|
|
step="30" value="<?php echo esc_attr(get_option('igsp_auto_delete_days', 0)); ?>">
|
|
<span class="igsp-slider-value">
|
|
<?php
|
|
$days = get_option('igsp_auto_delete_days', 0);
|
|
echo $days === 0 ? esc_html__('Never', 'instagram-gallery-sync-pro') : esc_html($days . ' ' . __('days', 'instagram-gallery-sync-pro'));
|
|
?>
|
|
</span>
|
|
</div>
|
|
<p class="description">
|
|
<?php esc_html_e('Automatically delete posts older than X days. Set to 0 to disable.', 'instagram-gallery-sync-pro'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="igsp-section">
|
|
<h2>
|
|
<?php esc_html_e('Request Configuration', 'instagram-gallery-sync-pro'); ?>
|
|
</h2>
|
|
|
|
<table class="form-table">
|
|
<tr>
|
|
<th scope="row">
|
|
<label for="igsp_user_agent">
|
|
<?php esc_html_e('Custom User-Agent', 'instagram-gallery-sync-pro'); ?>
|
|
</label>
|
|
</th>
|
|
<td>
|
|
<input type="text" id="igsp_user_agent" name="igsp_user_agent"
|
|
value="<?php echo esc_attr(get_option('igsp_user_agent', '')); ?>" class="large-text"
|
|
placeholder="<?php esc_attr_e('Leave empty to use rotating User-Agents', 'instagram-gallery-sync-pro'); ?>">
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row">
|
|
<?php esc_html_e('Proxy Settings', 'instagram-gallery-sync-pro'); ?>
|
|
</th>
|
|
<td>
|
|
<div class="igsp-inline-fields">
|
|
<input type="text" id="igsp_proxy_host" name="igsp_proxy_host"
|
|
value="<?php echo esc_attr(get_option('igsp_proxy_host', '')); ?>"
|
|
placeholder="<?php esc_attr_e('Proxy Host', 'instagram-gallery-sync-pro'); ?>"
|
|
class="regular-text">
|
|
<input type="number" id="igsp_proxy_port" name="igsp_proxy_port"
|
|
value="<?php echo esc_attr(get_option('igsp_proxy_port', '')); ?>"
|
|
placeholder="<?php esc_attr_e('Port', 'instagram-gallery-sync-pro'); ?>"
|
|
class="small-text" min="1" max="65535">
|
|
</div>
|
|
<p class="description">
|
|
<?php esc_html_e('Optional: Use a proxy for Instagram requests.', 'instagram-gallery-sync-pro'); ?>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<?php submit_button(); ?>
|
|
</form>
|
|
|
|
<div class="igsp-section igsp-actions-section">
|
|
<h2>
|
|
<?php esc_html_e('Tools', 'instagram-gallery-sync-pro'); ?>
|
|
</h2>
|
|
|
|
<div class="igsp-tools-grid">
|
|
<div class="igsp-tool-card">
|
|
<h3>
|
|
<?php esc_html_e('Clear Cache', 'instagram-gallery-sync-pro'); ?>
|
|
</h3>
|
|
<p>
|
|
<?php esc_html_e('Clear all cached gallery data.', 'instagram-gallery-sync-pro'); ?>
|
|
</p>
|
|
<button type="button" id="igsp-clear-cache" class="button">
|
|
<span class="dashicons dashicons-trash"></span>
|
|
<?php esc_html_e('Clear Cache', 'instagram-gallery-sync-pro'); ?>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="igsp-tool-card">
|
|
<h3>
|
|
<?php esc_html_e('Storage Used', 'instagram-gallery-sync-pro'); ?>
|
|
</h3>
|
|
<p>
|
|
<?php echo esc_html(sprintf(__('Total: %s', 'instagram-gallery-sync-pro'), $image_handler->get_storage_used_formatted())); ?>
|
|
</p>
|
|
</div>
|
|
|
|
<div class="igsp-tool-card igsp-tool-danger">
|
|
<h3>
|
|
<?php esc_html_e('Reset All Data', 'instagram-gallery-sync-pro'); ?>
|
|
</h3>
|
|
<p>
|
|
<?php esc_html_e('Delete ALL Instagram data, images, and logs.', 'instagram-gallery-sync-pro'); ?>
|
|
</p>
|
|
<button type="button" id="igsp-reset-data" class="button button-danger">
|
|
<span class="dashicons dashicons-warning"></span>
|
|
<?php esc_html_e('Reset Everything', 'instagram-gallery-sync-pro'); ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="igsp-section igsp-logs-section">
|
|
<div class="igsp-logs-header">
|
|
<h2>
|
|
<?php esc_html_e('Activity Logs', 'instagram-gallery-sync-pro'); ?>
|
|
</h2>
|
|
<button type="button" id="igsp-clear-logs" class="button button-small">
|
|
<?php esc_html_e('Clear Logs', 'instagram-gallery-sync-pro'); ?>
|
|
</button>
|
|
</div>
|
|
|
|
<?php if (empty($logs)): ?>
|
|
<p class="igsp-no-logs">
|
|
<?php esc_html_e('No log entries yet. Enable debug mode to see activity logs.', 'instagram-gallery-sync-pro'); ?>
|
|
</p>
|
|
<?php else: ?>
|
|
<div class="igsp-logs-table-wrapper">
|
|
<table class="igsp-logs-table widefat">
|
|
<thead>
|
|
<tr>
|
|
<th class="igsp-log-type">
|
|
<?php esc_html_e('Type', 'instagram-gallery-sync-pro'); ?>
|
|
</th>
|
|
<th class="igsp-log-message">
|
|
<?php esc_html_e('Message', 'instagram-gallery-sync-pro'); ?>
|
|
</th>
|
|
<th class="igsp-log-date">
|
|
<?php esc_html_e('Date', 'instagram-gallery-sync-pro'); ?>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($logs as $log): ?>
|
|
<tr class="<?php echo esc_attr($log['type_class']); ?>">
|
|
<td>
|
|
<span class="igsp-log-badge igsp-log-<?php echo esc_attr($log['type']); ?>">
|
|
<?php echo esc_html($log['type_label']); ?>
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<?php echo esc_html($log['message']); ?>
|
|
</td>
|
|
<td title="<?php echo esc_attr($log['date']); ?>">
|
|
<?php echo esc_html($log['relative']); ?>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|