font handling fix
This commit is contained in:
parent
d5ecb31dad
commit
fda7bd1d12
6 changed files with 727 additions and 22 deletions
|
|
@ -23,6 +23,39 @@ class MLF_Admin_Page {
|
|||
// Empty constructor - class is instantiated for rendering
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle settings form submission.
|
||||
*/
|
||||
private function handle_settings_save() {
|
||||
if (!isset($_POST['mlf_save_settings'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify nonce
|
||||
if (!isset($_POST['mlf_settings_nonce']) || !wp_verify_nonce($_POST['mlf_settings_nonce'], 'mlf_save_settings')) {
|
||||
add_settings_error('mlf_settings', 'nonce_error', __('Security check failed.', 'maple-local-fonts'), 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify capability
|
||||
$capability = function_exists('mlf_get_capability') ? mlf_get_capability() : 'edit_theme_options';
|
||||
if (!current_user_can($capability)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save compatibility mode setting
|
||||
$compatibility_mode = isset($_POST['mlf_compatibility_mode']) && $_POST['mlf_compatibility_mode'] === '1';
|
||||
update_option('mlf_compatibility_mode', $compatibility_mode);
|
||||
|
||||
// Clear font caches to apply new URL format
|
||||
delete_transient('mlf_imported_fonts_list');
|
||||
if (class_exists('WP_Theme_JSON_Resolver')) {
|
||||
WP_Theme_JSON_Resolver::clean_cached_data();
|
||||
}
|
||||
|
||||
add_settings_error('mlf_settings', 'settings_saved', __('Settings saved.', 'maple-local-fonts'), 'success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the admin page.
|
||||
*/
|
||||
|
|
@ -32,11 +65,15 @@ class MLF_Admin_Page {
|
|||
wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'maple-local-fonts'));
|
||||
}
|
||||
|
||||
// Handle settings save
|
||||
$this->handle_settings_save();
|
||||
|
||||
$registry = new MLF_Font_Registry();
|
||||
$installed_fonts = $registry->get_imported_fonts();
|
||||
?>
|
||||
<div class="wrap mlf-wrap">
|
||||
<h1><?php esc_html_e('Maple Fonts', 'maple-local-fonts'); ?></h1>
|
||||
<?php settings_errors('mlf_settings'); ?>
|
||||
<p class="mlf-description"><?php esc_html_e('Import Google Fonts to your local server for privacy-friendly, GDPR-compliant typography.', 'maple-local-fonts'); ?></p>
|
||||
|
||||
<div class="mlf-container">
|
||||
|
|
@ -162,6 +199,28 @@ class MLF_Admin_Page {
|
|||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- Settings Section -->
|
||||
<div class="mlf-section mlf-settings-section">
|
||||
<h2><?php esc_html_e('Settings', 'maple-local-fonts'); ?></h2>
|
||||
<form method="post" action="">
|
||||
<?php wp_nonce_field('mlf_save_settings', 'mlf_settings_nonce'); ?>
|
||||
<div class="mlf-form-row">
|
||||
<label class="mlf-checkbox-label mlf-setting-toggle">
|
||||
<input type="checkbox" name="mlf_compatibility_mode" value="1" <?php checked(get_option('mlf_compatibility_mode', true)); ?> />
|
||||
<span><strong><?php esc_html_e('Compatibility Mode', 'maple-local-fonts'); ?></strong></span>
|
||||
</label>
|
||||
<p class="description">
|
||||
<?php esc_html_e('Enable this if fonts are not loading on mobile devices or behind reverse proxies (Caddy, Nginx, Cloudflare). This serves fonts through WordPress for guaranteed header compatibility.', 'maple-local-fonts'); ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="mlf-form-row mlf-form-row-submit">
|
||||
<button type="submit" name="mlf_save_settings" class="button button-secondary">
|
||||
<?php esc_html_e('Save Settings', 'maple-local-fonts'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Info Section -->
|
||||
<div class="mlf-section mlf-info-section">
|
||||
<?php if (wp_is_block_theme()) : ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue