font management fixes

This commit is contained in:
rodolfomartinez 2026-02-02 08:31:36 -05:00
parent 847ed92c23
commit d5ecb31dad
8 changed files with 728 additions and 99 deletions

View file

@ -49,15 +49,17 @@ class MLF_Admin_Page {
<div class="mlf-form-row">
<label for="mlf-font-search"><?php esc_html_e('Search Fonts', 'maple-local-fonts'); ?></label>
<div class="mlf-search-wrapper">
<span class="dashicons dashicons-search mlf-search-icon"></span>
<input type="text"
id="mlf-font-search"
class="mlf-search-input"
placeholder="<?php esc_attr_e('Search Google Fonts...', 'maple-local-fonts'); ?>"
placeholder="<?php esc_attr_e('Enter font name...', 'maple-local-fonts'); ?>"
autocomplete="off" />
<button type="button" class="button mlf-search-btn" id="mlf-search-btn">
<?php esc_html_e('Search', 'maple-local-fonts'); ?>
</button>
<span class="spinner mlf-search-spinner" id="mlf-search-spinner"></span>
</div>
<p class="description"><?php esc_html_e('Type at least 2 characters to search.', 'maple-local-fonts'); ?></p>
<p class="description"><?php esc_html_e('Enter at least 2 characters and click Search.', 'maple-local-fonts'); ?></p>
</div>
<!-- Search Results -->
@ -99,22 +101,32 @@ class MLF_Admin_Page {
<div class="mlf-info-note">
<span class="dashicons dashicons-info-outline"></span>
<span><?php esc_html_e('All font weights (100-900) will be downloaded automatically. Variable fonts are used when available for better performance.', 'maple-local-fonts'); ?></span>
<span><?php esc_html_e('Weights 300-900 (Light to Black) will be downloaded. Variable fonts are used when available, which include all weights in a single efficient file.', 'maple-local-fonts'); ?></span>
</div>
</div>
<!-- Installed Fonts Section -->
<div class="mlf-section mlf-installed-section">
<h2><?php esc_html_e('Installed Fonts', 'maple-local-fonts'); ?></h2>
<div class="mlf-section-header">
<h2><?php esc_html_e('Installed Fonts', 'maple-local-fonts'); ?></h2>
<?php if (!empty($installed_fonts)) : ?>
<button type="button" class="button mlf-check-updates-btn" id="mlf-check-updates">
<?php esc_html_e('Check for Updates', 'maple-local-fonts'); ?>
</button>
<?php endif; ?>
</div>
<?php if (empty($installed_fonts)) : ?>
<p class="mlf-no-fonts"><?php esc_html_e('No fonts installed yet. Search and select a font above to get started.', 'maple-local-fonts'); ?></p>
<?php else : ?>
<div id="mlf-font-list" class="mlf-font-list">
<?php foreach ($installed_fonts as $font) : ?>
<div class="mlf-font-item" data-font-id="<?php echo esc_attr($font['id']); ?>">
<div class="mlf-font-item" data-font-id="<?php echo esc_attr($font['id']); ?>" data-font-name="<?php echo esc_attr($font['name']); ?>" data-font-version="<?php echo esc_attr($font['version']); ?>">
<div class="mlf-font-info">
<h3 class="mlf-font-name"><?php echo esc_html($font['name']); ?></h3>
<div class="mlf-font-header">
<h3 class="mlf-font-name"><?php echo esc_html($font['name']); ?></h3>
<span class="mlf-update-badge" style="display: none;"><?php esc_html_e('Update available', 'maple-local-fonts'); ?></span>
</div>
<p class="mlf-font-variants">
<?php
$variant_strings = [];
@ -124,8 +136,22 @@ class MLF_Admin_Page {
echo esc_html(implode(', ', $variant_strings));
?>
</p>
<p class="mlf-font-meta">
<?php if (!empty($font['version'])) : ?>
<span class="mlf-font-version"><?php echo esc_html($font['version']); ?></span>
<?php endif; ?>
<?php if (!empty($font['last_modified'])) : ?>
<span class="mlf-font-modified"><?php
/* translators: %s: date */
printf(esc_html__('Updated: %s', 'maple-local-fonts'), esc_html($font['last_modified']));
?></span>
<?php endif; ?>
</p>
</div>
<div class="mlf-font-actions">
<button type="button" class="button mlf-update-btn" data-font-id="<?php echo esc_attr($font['id']); ?>" data-font-name="<?php echo esc_attr($font['name']); ?>" style="display: none;">
<?php esc_html_e('Update', 'maple-local-fonts'); ?>
</button>
<button type="button" class="button mlf-delete-btn" data-font-id="<?php echo esc_attr($font['id']); ?>">
<?php esc_html_e('Delete', 'maple-local-fonts'); ?>
</button>