Plugin Directory

Changeset 3395519


Ignore:
Timestamp:
11/14/2025 07:13:28 AM (4 months ago)
Author:
chrmrtns
Message:

Version 1.1.9 - Add CSS variables support and CSS Reference page

  • NEW: CSS variables output for all fonts - enables manual font selection in custom CSS and builders supporting CSS custom properties
  • NEW: CSS Reference page - comprehensive documentation for CSS variables, Gutenberg classes, and implementation details
  • Added CssReferencePage.php class for CSS documentation
  • Updated FontManager.php to generate CSS variables in :root
  • Updated AdminInterface.php to add CSS Reference menu item
  • Updated readme.txt with CSS variables feature documentation
Location:
safefonts
Files:
35 added
5 edited

Legend:

Unmodified
Added
Removed
  • safefonts/trunk/includes/Admin/AdminInterface.php

    r3394862 r3395519  
    8383            'safefonts-settings',
    8484            array($this, 'settings_page')
     85        );
     86
     87        // CSS Reference submenu
     88        add_submenu_page(
     89            'safefonts',
     90            __('CSS Reference', 'safefonts'),
     91            __('CSS Reference', 'safefonts'),
     92            'manage_options',
     93            'safefonts-css-reference',
     94            array($this, 'css_reference_page')
    8595        );
    8696
     
    247257    public function help_page() {
    248258        include CHRMRTNS_SAFEFONTS_PLUGIN_DIR . 'views/help-page.php';
     259    }
     260
     261    /**
     262     * CSS Reference page
     263     */
     264    public function css_reference_page() {
     265        $page = new \Chrmrtns\SafeFonts\Admin\CssReferencePage(chrmrtns_safefonts()->font_manager);
     266        $page->render();
    249267    }
    250268
     
    535553                                        .safefonts-preload-family-name { font-weight: 600; margin-bottom: 5px; cursor: pointer; }
    536554                                        .safefonts-preload-family-name:hover { color: #2271b1; }
    537                                         .safefonts-preload-weights { margin-left: 25px; }
     555                                        .safefonts-preload-weights { margin-left: 25px; display: flex; flex-direction: column; }
    538556                                        .safefonts-preload-weights label { display: block; margin: 3px 0; }
    539557                                    </style>
     
    541559                                    <?php foreach ($fonts_grouped as $family => $weights): ?>
    542560                                        <div class="safefonts-preload-family">
    543                                             <div class="safefonts-preload-family-name" onclick="this.nextElementSibling.style.display = this.nextElementSibling.style.display === 'none' ? 'block' : 'none';">
     561                                            <div class="safefonts-preload-family-name" onclick="this.nextElementSibling.style.display = this.nextElementSibling.style.display === 'none' ? 'flex' : 'none';">
    544562                                                ▸ <?php echo esc_html($family); ?> <span style="font-weight: normal; font-size: 0.9em; color: #666;">(<?php echo count($weights); ?> <?php esc_html_e('weights', 'safefonts'); ?>)</span>
    545563                                            </div>
  • safefonts/trunk/includes/Core.php

    r3394862 r3395519  
    465465        }
    466466
    467         // Check if SafeFonts was updated
    468         if (isset($options['plugins'])) {
     467        $plugin_basename = plugin_basename(CHRMRTNS_SAFEFONTS_PLUGIN_FILE);
     468
     469        // Check if SafeFonts was updated (handle both single and bulk updates)
     470        if (isset($options['plugin']) && $options['plugin'] === $plugin_basename) {
     471            // Single plugin update
     472            $this->generate_fonts_css();
     473        } elseif (isset($options['plugins']) && is_array($options['plugins'])) {
     474            // Bulk plugin update
    469475            foreach ($options['plugins'] as $plugin) {
    470                 if ($plugin === plugin_basename(CHRMRTNS_SAFEFONTS_PLUGIN_FILE)) {
    471                     // Regenerate CSS silently
     476                if ($plugin === $plugin_basename) {
    472477                    $this->generate_fonts_css();
    473478                    break;
  • safefonts/trunk/includes/FontManager.php

    r3393584 r3395519  
    102102        $css = "/* SafeFonts - Generated CSS */\n";
    103103        $css .= "/* Generated: " . current_time('mysql') . " */\n\n";
     104        $css .= "/* ================================= */\n";
     105        $css .= "/*   CSS VARIABLES                  */\n";
     106        $css .= "/* ================================= */\n\n";
     107
     108        $fonts_by_family = $this->get_fonts_by_family();
     109
     110        if (!empty($fonts_by_family)) {
     111            $css .= ":root {\n";
     112            foreach ($fonts_by_family as $family => $variants) {
     113                $slug = sanitize_title($family);
     114                $fallback = $this->get_font_fallback($family);
     115                $css .= "  --safefonts-" . $slug . ": '" . esc_attr($family) . "'" . $fallback . ";\n";
     116            }
     117            $css .= "}\n\n";
     118        }
     119
    104120        $css .= "/* ================================= */\n";
    105121        $css .= "/*   FONT FACE DECLARATIONS         */\n";
     
    365381     * @return string Fallback font stack
    366382     */
    367     private function get_font_fallback($family_name) {
     383    public function get_font_fallback($family_name) {
    368384        $family_lower = strtolower($family_name);
    369385
  • safefonts/trunk/readme.txt

    r3394862 r3395519  
    44Requires at least: 6.2
    55Tested up to: 6.8
    6 Stable tag: 1.1.8
     6Stable tag: 1.1.9
    77Requires PHP: 7.4
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Host custom fonts locally in WordPress with advanced security validation and block editor integration.
     11Host custom fonts locally in WordPress with advanced security validation, block editor integration, and CSS variables support.
    1212
    1313== Description ==
    1414
    15 **SafeFonts helps you comply with GDPR by hosting fonts locally and avoiding third-party requests, with seamless Gutenberg integration.**
    16 
    17 If you need to host custom fonts locally on your WordPress site for performance, privacy, or GDPR compliance, SafeFonts makes it simple with advanced security validation and automatic integration with the WordPress block editor.
     15**SafeFonts helps you comply with GDPR by hosting fonts locally and avoiding third-party requests, with seamless Gutenberg integration and CSS variables support.**
     16
     17If you need to host custom fonts locally on your WordPress site for performance, privacy, or GDPR compliance, SafeFonts makes it simple with advanced security validation, automatic integration with the WordPress block editor, and CSS variables for custom CSS usage.
    1818
    1919= Compatible With =
     
    2525
    2626**Need Page Builder Integration?**
    27 [SafeFonts Pro](https://safefonts.com) adds seamless support for Elementor, Bricks, Beaver Builder, Divi, Oxygen, Brizy, Astra, GeneratePress, and GenerateBlocks with zero configuration.
     27[SafeFonts Pro](https://safefonts.com) adds seamless support for 14 integrations: Elementor, Bricks, Beaver Builder, Divi, Oxygen, Brizy, Builderius, Astra, GeneratePress, Kadence, Blocksy, Kadence Blocks, Spectra, and GenerateBlocks with zero configuration.
    2828
    2929= Why Choose SafeFonts? =
     
    4747* Works with all blocks that support typography
    4848* No configuration needed
     49
     50**🎨 CSS Variables Support**
     51* Automatic CSS variables generation for all fonts
     52* Use var(--safefonts-font-slug) in custom CSS
     53* Works with any theme or builder supporting CSS custom properties
     54* Dedicated CSS Reference page with comprehensive documentation
    4955
    5056**🎥 Quick Start Video**
     
    86921. **Upload Fonts**: Go to SafeFonts menu and upload your font files
    87932. **Configure Details**: Set font family name, weight (100-900), and style (normal/italic)
    88 3. **Use in Gutenberg**: Your fonts automatically appear in the block editor
     943. **Use Everywhere**: Your fonts automatically appear in:
     95   - Gutenberg block editor typography settings
     96   - CSS variables for custom CSS (check CSS Reference page)
     97   - WordPress 6.5+ Font Library
    89984. **That's It!** Fonts are served locally with optimal performance
    9099
     
    1351443. **Upload File**: Choose your font file (.woff2 recommended)
    1361454. **Use in Gutenberg**: Your font now appears in block typography settings
     1465. **Check CSS Reference**: Visit SafeFonts > CSS Reference to see your CSS variables and implementation details
    137147
    138148== Frequently Asked Questions ==
     
    156166= Can I use this with page builders? =
    157167
    158 The free version works with Gutenberg. For page builder and theme integration (Elementor, Bricks, Beaver Builder, Divi, Oxygen, Brizy, GeneratePress, GenerateBlocks), check out [SafeFonts Pro](https://safefonts.com).
     168The free version works with Gutenberg and provides CSS variables that can be manually used with any builder or theme supporting CSS custom properties (like Builderius, Bricks, Oxygen, and others). Simply use var(--safefonts-font-slug) in typography fields or custom CSS.
     169
     170For automatic integration (14 integrations including Elementor, Bricks, Beaver Builder, Divi, Oxygen, Brizy, Builderius, Astra, GeneratePress, Kadence, Blocksy, Kadence Blocks, Spectra, and GenerateBlocks) where fonts appear directly in builder dropdowns, check out [SafeFonts Pro](https://safefonts.com).
    159171
    160172= How does the security validation work? =
     
    180192* Individual font file uploads
    181193* Gutenberg integration
     194* CSS variables for custom CSS usage
     195* CSS Reference page with documentation
    182196* Security validation
    183197* WordPress 6.5+ Font Library support
    184198
    185199SafeFonts Pro adds:
    186 * Page builder & theme integration (8 integrations: Elementor, Bricks, Beaver Builder, Divi, Oxygen, Brizy, GeneratePress, GenerateBlocks)
     200* Page builder & theme integration (14 integrations: Elementor, Bricks, Beaver Builder, Divi, Oxygen, Brizy, Builderius, Astra, GeneratePress, Kadence, Blocksy, Kadence Blocks, Spectra, GenerateBlocks)
    187201* Bulk ZIP package imports from Google Fonts Downloader
    188202* Enhanced admin interface with bulk operations
    189 * Advanced font management tools (family deletion, Brizy sync, etc.)
     203* Advanced font management tools (family deletion, CSS variables, etc.)
    190204
    191205[Learn more](https://safefonts.com)
     
    209223
    210224== Changelog ==
     225
     226= 1.1.9 =
     227* NEW: CSS variables output for all fonts - enables manual font selection in custom CSS and builders supporting CSS custom properties
     228* NEW: CSS Reference page - comprehensive documentation for CSS variables, Gutenberg classes, and implementation details
     229* FIX: Auto-regeneration now works correctly for both single plugin updates and bulk updates
     230* FIX: CSS regeneration hook now properly detects updates from all update methods
    211231
    212232= 1.1.8 =
  • safefonts/trunk/safefonts.php

    r3394862 r3395519  
    44 * Plugin URI: https://safefonts.com
    55 * Description: Secure font management for WordPress with Gutenberg integration and local hosting for GDPR compliance.
    6  * Version: 1.1.8
     6 * Version: 1.1.9
    77 * Requires at least: 6.2
    88 * Requires PHP: 7.4
     
    2121
    2222// Define plugin constants
    23 define('CHRMRTNS_SAFEFONTS_VERSION', '1.1.8');
     23define('CHRMRTNS_SAFEFONTS_VERSION', '1.1.9');
    2424define('CHRMRTNS_SAFEFONTS_PLUGIN_FILE', __FILE__);
    2525define('CHRMRTNS_SAFEFONTS_PLUGIN_DIR', plugin_dir_path(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.