Changeset 3394862
- Timestamp:
- 11/13/2025 09:21:31 AM (4 months ago)
- Location:
- safefonts/trunk
- Files:
-
- 5 edited
-
assets/js/admin.js (modified) (2 diffs)
-
includes/Admin/AdminInterface.php (modified) (2 diffs)
-
includes/Core.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
safefonts.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
safefonts/trunk/assets/js/admin.js
r3390097 r3394862 12 12 this.initBulkActions(); 13 13 this.initTabs(); 14 this.initCssRegeneration(); 14 15 }, 15 16 … … 173 174 $('.safefonts-tab-content').hide(); 174 175 $(target).show(); 176 }); 177 }, 178 179 initCssRegeneration: function() { 180 $('#safefonts-regenerate-css').on('click', function(e) { 181 e.preventDefault(); 182 SafeFontsAdmin.handleCssRegeneration($(this)); 183 }); 184 }, 185 186 handleCssRegeneration: function($button) { 187 const nonce = $button.data('nonce'); 188 const $result = $('#safefonts-regenerate-css-result'); 189 190 // Disable button and show loading state 191 $button.prop('disabled', true); 192 $button.text(safefontsAjax.strings.regenerating); 193 $result.empty(); 194 195 $.ajax({ 196 url: safefontsAjax.ajaxurl, 197 type: 'POST', 198 data: { 199 action: 'regenerate_safefonts_css', 200 nonce: nonce 201 }, 202 success: function(response) { 203 $button.prop('disabled', false); 204 $button.text('Regenerate CSS'); 205 206 if (response.success) { 207 $result.html('<div class="notice notice-success inline"><p>' + response.data + '</p></div>'); 208 209 // Clear success message after 5 seconds 210 setTimeout(function() { 211 $result.fadeOut(300, function() { 212 $(this).empty().show(); 213 }); 214 }, 5000); 215 } else { 216 $result.html('<div class="notice notice-error inline"><p>' + safefontsAjax.strings.regenerate_error + ': ' + response.data + '</p></div>'); 217 } 218 }, 219 error: function() { 220 $button.prop('disabled', false); 221 $button.text('Regenerate CSS'); 222 $result.html('<div class="notice notice-error inline"><p>' + safefontsAjax.strings.regenerate_error + '</p></div>'); 223 } 175 224 }); 176 225 }, -
safefonts/trunk/includes/Admin/AdminInterface.php
r3393584 r3394862 154 154 'delete_error' => __('Failed to delete font', 'safefonts'), 155 155 'font_family_required' => __('Font family name is required', 'safefonts'), 156 'regenerating' => __('Regenerating CSS...', 'safefonts'), 157 'regenerate_success' => __('CSS regenerated successfully!', 'safefonts'), 158 'regenerate_error' => __('Failed to regenerate CSS', 'safefonts'), 156 159 ) 157 160 )); … … 592 595 </td> 593 596 </tr> 597 598 <tr> 599 <th scope="row"> 600 <?php esc_html_e('Font CSS', 'safefonts'); ?> 601 </th> 602 <td> 603 <button type="button" 604 id="safefonts-regenerate-css" 605 class="button" 606 data-nonce="<?php echo esc_attr(wp_create_nonce('regenerate_safefonts_css')); ?>"> 607 <?php esc_html_e('Regenerate CSS', 'safefonts'); ?> 608 </button> 609 <p class="description"> 610 <?php esc_html_e('Manually regenerate the fonts.css file. This is useful if fonts aren\'t displaying correctly after an update.', 'safefonts'); ?> 611 </p> 612 <div id="safefonts-regenerate-css-result" style="margin-top: 10px;"></div> 613 </td> 614 </tr> 594 615 </table> 595 616 -
safefonts/trunk/includes/Core.php
r3394834 r3394862 106 106 add_action('init', array($this, 'register_font_collection')); 107 107 } 108 109 // AJAX handler for CSS regeneration 110 add_action('wp_ajax_regenerate_safefonts_css', array($this, 'handle_regenerate_css_ajax')); 111 112 // Auto-regenerate CSS after plugin updates 113 add_action('upgrader_process_complete', array($this, 'regenerate_css_after_update'), 10, 2); 108 114 109 115 // Register activation/deactivation hooks … … 420 426 // Default to sans-serif 421 427 return 'sans-serif'; 428 } 429 430 /** 431 * AJAX handler for CSS regeneration 432 * 433 * @return void 434 */ 435 public function handle_regenerate_css_ajax() { 436 // Verify nonce 437 check_ajax_referer('regenerate_safefonts_css', 'nonce'); 438 439 // Check user permissions 440 if (!current_user_can('manage_options')) { 441 wp_send_json_error(__('Insufficient permissions', 'safefonts')); 442 } 443 444 // Regenerate CSS 445 $result = $this->generate_fonts_css(); 446 447 if ($result) { 448 wp_send_json_success(__('Font CSS successfully regenerated!', 'safefonts')); 449 } else { 450 wp_send_json_error(__('Failed to regenerate CSS file. Please check file permissions.', 'safefonts')); 451 } 452 } 453 454 /** 455 * Regenerate CSS after plugin update 456 * 457 * @param \WP_Upgrader $upgrader Upgrader instance 458 * @param array $options Update options 459 * @return void 460 */ 461 public function regenerate_css_after_update($upgrader, $options) { 462 // Check if this is a plugin update 463 if ($options['type'] !== 'plugin' || $options['action'] !== 'update') { 464 return; 465 } 466 467 // Check if SafeFonts was updated 468 if (isset($options['plugins'])) { 469 foreach ($options['plugins'] as $plugin) { 470 if ($plugin === plugin_basename(CHRMRTNS_SAFEFONTS_PLUGIN_FILE)) { 471 // Regenerate CSS silently 472 $this->generate_fonts_css(); 473 break; 474 } 475 } 476 } 422 477 } 423 478 -
safefonts/trunk/readme.txt
r3394846 r3394862 4 4 Requires at least: 6.2 5 5 Tested up to: 6.8 6 Stable tag: 1.1. 76 Stable tag: 1.1.8 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 209 209 210 210 == Changelog == 211 212 = 1.1.8 = 213 * NEW: Manual CSS regeneration button in Settings page for refreshing fonts.css when needed 214 * NEW: Automatic CSS regeneration after plugin updates to prevent font display issues 215 * IMPROVEMENT: fonts.css automatically regenerates when plugin is updated via WordPress auto-update or manual update 211 216 212 217 = 1.1.7 = -
safefonts/trunk/safefonts.php
r3394834 r3394862 4 4 * Plugin URI: https://safefonts.com 5 5 * Description: Secure font management for WordPress with Gutenberg integration and local hosting for GDPR compliance. 6 * Version: 1.1. 76 * Version: 1.1.8 7 7 * Requires at least: 6.2 8 8 * Requires PHP: 7.4 … … 21 21 22 22 // Define plugin constants 23 define('CHRMRTNS_SAFEFONTS_VERSION', '1.1. 7');23 define('CHRMRTNS_SAFEFONTS_VERSION', '1.1.8'); 24 24 define('CHRMRTNS_SAFEFONTS_PLUGIN_FILE', __FILE__); 25 25 define('CHRMRTNS_SAFEFONTS_PLUGIN_DIR', plugin_dir_path(__FILE__));
Note: See TracChangeset
for help on using the changeset viewer.