Changeset 3323421
- Timestamp:
- 07/07/2025 10:35:04 AM (9 months ago)
- Location:
- olympus-google-fonts
- Files:
-
- 32 edited
- 1 copied
-
tags/3.9.5 (copied) (copied from olympus-google-fonts/trunk)
-
tags/3.9.5/admin/class-ogf-upload-fonts-screen.php (modified) (5 diffs)
-
tags/3.9.5/assets/js/uploadFonts.js (modified) (1 diff)
-
tags/3.9.5/blocks/src/google-fonts/edit.js (modified) (1 diff)
-
tags/3.9.5/changelog.txt (modified) (1 diff)
-
tags/3.9.5/class-olympus-google-fonts.php (modified) (3 diffs)
-
tags/3.9.5/includes/class-ogf-classic-editor.php (modified) (1 diff)
-
tags/3.9.5/includes/class-ogf-clear-cache.php (modified) (1 diff)
-
tags/3.9.5/includes/class-ogf-fonts.php (modified) (5 diffs)
-
tags/3.9.5/includes/class-ogf-typekit.php (modified) (3 diffs)
-
tags/3.9.5/includes/customizer/output-css.php (modified) (5 diffs)
-
tags/3.9.5/includes/customizer/settings.php (modified) (1 diff)
-
tags/3.9.5/includes/functions.php (modified) (2 diffs)
-
tags/3.9.5/includes/gutenberg/class-ogf-gutenberg-filters.php (modified) (1 diff)
-
tags/3.9.5/includes/gutenberg/output-css.php (modified) (2 diffs)
-
tags/3.9.5/olympus-google-fonts.php (modified) (1 diff)
-
tags/3.9.5/readme.txt (modified) (1 diff)
-
trunk/admin/class-ogf-upload-fonts-screen.php (modified) (5 diffs)
-
trunk/assets/js/uploadFonts.js (modified) (1 diff)
-
trunk/blocks/src/google-fonts/edit.js (modified) (1 diff)
-
trunk/changelog.txt (modified) (1 diff)
-
trunk/class-olympus-google-fonts.php (modified) (3 diffs)
-
trunk/includes/class-ogf-classic-editor.php (modified) (1 diff)
-
trunk/includes/class-ogf-clear-cache.php (modified) (1 diff)
-
trunk/includes/class-ogf-fonts.php (modified) (5 diffs)
-
trunk/includes/class-ogf-typekit.php (modified) (3 diffs)
-
trunk/includes/customizer/output-css.php (modified) (5 diffs)
-
trunk/includes/customizer/settings.php (modified) (1 diff)
-
trunk/includes/functions.php (modified) (2 diffs)
-
trunk/includes/gutenberg/class-ogf-gutenberg-filters.php (modified) (1 diff)
-
trunk/includes/gutenberg/output-css.php (modified) (2 diffs)
-
trunk/olympus-google-fonts.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
olympus-google-fonts/tags/3.9.5/admin/class-ogf-upload-fonts-screen.php
r3100693 r3323421 97 97 $parent_file = $this->parent_menu_slug; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited 98 98 } 99 if ( get_current_screen()->id != 'edit-' . OGF_Fonts_Taxonomy::$taxonomy_slug ) { 99 $screen = get_current_screen(); 100 if ( ! $screen || $screen->id != 'edit-' . OGF_Fonts_Taxonomy::$taxonomy_slug ) { 100 101 return; 101 102 } … … 118 119 public function manage_columns( $columns ) { 119 120 $screen = get_current_screen(); 121 if ( ! $screen || $screen->id != 'edit-' . OGF_Fonts_Taxonomy::$taxonomy_slug ) { 122 return; 123 } 120 124 // If current screen is add new custom fonts screen. 121 125 if ( isset( $screen->base ) && 'edit-tags' == $screen->base ) { … … 417 421 418 422 /** 423 * Get the correct MIME type for a font file extension. 424 * 425 * @param string $extension The file extension. 426 * @return string The MIME type. 427 */ 428 private function get_font_mime_type( $extension ) { 429 switch ( $extension ) { 430 case 'ttf': 431 $php_7_ttf_mime_type = PHP_VERSION_ID >= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf'; 432 return PHP_VERSION_ID >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type; 433 434 case 'otf': 435 return 'application/vnd.ms-opentype'; 436 437 case 'woff': 438 return PHP_VERSION_ID >= 80112 ? 'font/woff' : 'application/font-woff'; 439 440 case 'woff2': 441 return PHP_VERSION_ID >= 80112 ? 'font/woff2' : 'application/font-woff2'; 442 443 default: 444 return ''; 445 } 446 } 447 448 /** 419 449 * Add WOFF and WOFF2 to the allowed mime types. 420 450 * … … 423 453 */ 424 454 public function add_to_allowed_mimes( $mimes ) { 425 426 $php_7_ttf_mime_type = PHP_VERSION_ID >= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf'; 427 428 $mimes['otf'] = 'application/vnd.ms-opentype'; 429 $mimes['ttf'] = PHP_VERSION_ID >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type; 430 $mimes['woff'] = PHP_VERSION_ID >= 80112 ? 'font/woff' : 'application/font-woff'; 431 $mimes['woff2'] = PHP_VERSION_ID >= 80112 ? 'font/woff2' : 'application/font-woff2'; 455 $mimes['otf'] = $this->get_font_mime_type( 'otf' ); 456 $mimes['ttf'] = $this->get_font_mime_type( 'ttf' ); 457 $mimes['woff'] = $this->get_font_mime_type( 'woff' ); 458 $mimes['woff2'] = $this->get_font_mime_type( 'woff2' ); 432 459 433 460 return $mimes; … … 445 472 */ 446 473 public function update_mime_types( $defaults, $file, $filename ) { 447 if ( 'ttf' === pathinfo( $filename, PATHINFO_EXTENSION ) ) {448 $defaults['type'] = 'application/x-font-ttf'; 449 $defaults['ext'] = 'ttf';450 }451 452 if ( 'otf' === pathinfo( $filename, PATHINFO_EXTENSION) ) {453 $defaults['type'] = 'application/x-font-otf';454 $defaults['ext'] = 'otf';474 $extension = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) ); 475 476 // Get the MIME type using the same logic as add_to_allowed_mimes(). 477 $mime_type = $this->get_font_mime_type( $extension ); 478 479 if ( ! empty( $mime_type ) ) { 480 $defaults['type'] = $mime_type; 481 $defaults['ext'] = $extension; 455 482 } 456 483 -
olympus-google-fonts/tags/3.9.5/assets/js/uploadFonts.js
r3100693 r3323421 51 51 file_frame.open(); 52 52 }); 53 var file_frame;54 window.inputWrapper = '';55 53 }, 56 54 } -
olympus-google-fonts/tags/3.9.5/blocks/src/google-fonts/edit.js
r3221683 r3323421 276 276 }, 277 277 { 278 value: ' 500',278 value: '600', 279 279 label: __('Semi Bold', 'olympus-google-fonts' ), 280 280 }, -
olympus-google-fonts/tags/3.9.5/changelog.txt
r3320024 r3323421 1 = 3.9.5 = 2 3 * Fix error when use Blubrry podcast plugin 4 * Fix null reference errors when get_current_screen() returns null 5 * Fix memory leak by implementing singleton pattern for font loading with backward compatibility 6 * Fix PHP 8.0+ compatibility by replacing str_starts_with() with strpos() 7 * Fix inconsistent MIME type handling for font file uploads 8 1 9 = 3.9.4 = 2 10 -
olympus-google-fonts/tags/3.9.5/class-olympus-google-fonts.php
r3320024 r3323421 39 39 public function constants() { 40 40 if ( ! defined( 'OGF_VERSION' ) ) { 41 define( 'OGF_VERSION', '3.9. 4' );41 define( 'OGF_VERSION', '3.9.5' ); 42 42 } 43 43 … … 134 134 */ 135 135 public function enqueue() { 136 $fonts = new OGF_Fonts();136 $fonts = OGF_Fonts::get_instance(); 137 137 138 138 if ( ! $fonts->has_google_fonts() ) { … … 165 165 } 166 166 167 $fonts = new OGF_Fonts();167 $fonts = OGF_Fonts::get_instance(); 168 168 169 169 // If no Google Fonts are being used we don't need this. -
olympus-google-fonts/tags/3.9.5/includes/class-ogf-classic-editor.php
r3243818 r3323421 50 50 } 51 51 52 $this->ogf_fonts = new OGF_Fonts();52 $this->ogf_fonts = OGF_Fonts::get_instance(); 53 53 $this->system_fonts = ogf_system_fonts(); 54 54 $this->custom_fonts = ogf_custom_fonts(); -
olympus-google-fonts/tags/3.9.5/includes/class-ogf-clear-cache.php
r3100693 r3323421 90 90 */ 91 91 public function clear() { 92 $fonts = new OGF_Fonts();92 $fonts = OGF_Fonts::get_instance(); 93 93 94 94 if ( $fonts->has_google_fonts() ) { -
olympus-google-fonts/tags/3.9.5/includes/class-ogf-fonts.php
r3100693 r3323421 27 27 28 28 /** 29 * Let's get started. 29 * Single instance of the class. 30 * 31 * @var OGF_Fonts|null 32 */ 33 private static $instance = null; 34 35 /** 36 * Get the singleton instance. 37 * 38 * @return OGF_Fonts 39 */ 40 public static function get_instance() { 41 if ( null === self::$instance ) { 42 self::$instance = new self(); 43 } 44 return self::$instance; 45 } 46 47 /** 48 * Constructor - made public for backward compatibility. 49 * External plugins/code can still use 'new OGF_Fonts()'. 30 50 */ 31 51 public function __construct() { 32 self::$google_fonts = ogf_fonts_array(); 52 // If this is not the singleton instance, just initialize normally for backward compatibility. 53 if ( null !== self::$instance && self::$instance !== $this ) { 54 // This is a separate instance for backward compatibility. 55 $this->initialize(); 56 return; 57 } 58 59 // This is the singleton instance. 60 $this->initialize(); 61 } 62 63 /** 64 * Initialize the font data and choices. 65 */ 66 private function initialize() { 67 // Only load fonts array if not already loaded. 68 if ( empty( self::$google_fonts ) ) { 69 self::$google_fonts = ogf_fonts_array(); 70 } 33 71 $this->get_choices(); 72 } 73 74 /** 75 * Prevent cloning of the instance. 76 */ 77 private function __clone() {} 78 79 /** 80 * Prevent unserialization of the instance. 81 * 82 * @throws Exception When attempting to unserialize. 83 */ 84 public function __wakeup() { 85 throw new Exception( 'Cannot unserialize singleton' ); 34 86 } 35 87 … … 78 130 */ 79 131 public function get_font_weights( $font_id ) { 132 // Check if font exists in the array. 133 if ( ! array_key_exists( $font_id, self::$google_fonts ) ) { 134 return array(); 135 } 136 137 // Check if the font has variants data. 138 if ( ! isset( self::$google_fonts[ $font_id ]['v'] ) ) { 139 return array(); 140 } 141 80 142 $weights = self::$google_fonts[ $font_id ]['v']; 81 143 … … 95 157 */ 96 158 public function get_font_subsets( $font_id ) { 159 // Check if font exists in the array. 160 if ( ! array_key_exists( $font_id, self::$google_fonts ) ) { 161 return array(); 162 } 163 164 // Check if the font has subsets data. 165 if ( ! isset( self::$google_fonts[ $font_id ]['s'] ) ) { 166 return array(); 167 } 168 97 169 $subsets = self::$google_fonts[ $font_id ]['s']; 98 170 … … 113 185 */ 114 186 public function get_font_name( $font_id ) { 115 if ( array_key_exists( $font_id, self::$google_fonts ) ) {187 if ( array_key_exists( $font_id, self::$google_fonts ) && isset( self::$google_fonts[ $font_id ]['f'] ) ) { 116 188 return self::$google_fonts[ $font_id ]['f']; 117 189 } else { … … 203 275 if ( false === ( $external_font_css ) ) { 204 276 // It wasn't there, so regenerate the data and save the transient. 205 $external_font_css = '/* Cached: ' . date( 'F j, Y \a\t g:ia' ) . ' */' . PHP_EOL;277 $external_font_css = '/* Cached: ' . gmdate( 'F j, Y \a\t g:ia' ) . ' */' . PHP_EOL; 206 278 $external_font_css .= $this->get_remote_url_contents( $url ) . PHP_EOL; 207 279 set_transient( 'ogf_external_font_css_' . $url_to_id, $external_font_css, DAY_IN_SECONDS ); -
olympus-google-fonts/tags/3.9.5/includes/class-ogf-typekit.php
r3128267 r3323421 138 138 */ 139 139 public function css_styles() { 140 if ( get_current_screen()->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 140 $screen = get_current_screen(); 141 if ( ! $screen || $screen->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 141 142 return; 142 143 } … … 159 160 160 161 // Only perform action on the Fonts Plugin Typekit Page. 161 if ( get_current_screen()->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 162 $screen = get_current_screen(); 163 if ( ! $screen || $screen->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 162 164 return; 163 165 } … … 231 233 public function manage_kits() { 232 234 // Only perform action on the Fonts Plugin Typekit Page. 233 if ( get_current_screen()->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 235 $screen = get_current_screen(); 236 if ( ! $screen || $screen->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 234 237 return; 235 238 } -
olympus-google-fonts/tags/3.9.5/includes/customizer/output-css.php
r3254070 r3323421 208 208 $cache_key = 'ogf_font_stack_' . md5( $font_id ); 209 209 $cached_stack = wp_cache_get( $cache_key ); 210 211 210 if ( $cached_stack !== false ) { 212 211 return $cached_stack; … … 216 215 $stack = ''; 217 216 218 if ( str_starts_with( $font_id, 'sf-' ) !== false) {217 if ( 0 === strpos( $font_id, 'sf-' ) ) { 219 218 $system_fonts = ogf_system_fonts(); 220 219 $font_id = str_replace( 'sf-', '', $font_id ); … … 223 222 $stack = $system_fonts[ $font_id ]['stack']; 224 223 } 225 } elseif ( str_starts_with( $font_id, 'cf-' ) !== false) {224 } elseif ( 0 === strpos( $font_id, 'cf-' ) ) { 226 225 $custom_fonts = ogf_custom_fonts(); 227 226 $font_id = str_replace( 'cf-', '', $font_id ); … … 235 234 $stack = '"' . $font . '"'; 236 235 } 237 } elseif ( str_starts_with( $font_id, 'tk-' ) !== false) {236 } elseif ( 0 === strpos( $font_id, 'tk-' ) ) { 238 237 $typekit_fonts = ogf_typekit_fonts(); 239 238 … … 250 249 251 250 // Cache the result. 252 wp_cache_set( $cache_key, $stack, 'ogf_font_stacks', HOUR_IN_SECONDS ); 253 251 wp_cache_set( $cache_key, $stack, 'ogf_font_stacks', HOUR_IN_SECONDS ); 254 252 // Allow filtering of the final stack. 255 253 return apply_filters( "ogf_{$font_id}_stack", $stack ); -
olympus-google-fonts/tags/3.9.5/includes/customizer/settings.php
r3100693 r3323421 298 298 ); 299 299 300 $fonts = new OGF_Fonts();300 $fonts = OGF_Fonts::get_instance(); 301 301 $subsets = array(); 302 302 -
olympus-google-fonts/tags/3.9.5/includes/functions.php
r3254070 r3323421 156 156 157 157 /** 158 * Get the OGF_Fonts singleton instance. 159 * 160 * @return OGF_Fonts The singleton instance. 161 */ 162 function ogf_get_fonts_instance() { 163 return OGF_Fonts::get_instance(); 164 } 165 166 167 168 /** 158 169 * Return an array of all available Google Fonts. 159 170 * … … 167 178 } 168 179 169 $fonts_json = file_get_contents( OGF_DIR_PATH . '/blocks/src/google-fonts/fonts.json' ); 170 171 // Change the object to a multidimensional array. 180 $fonts_file = OGF_DIR_PATH . '/blocks/src/google-fonts/fonts.json'; 181 182 if ( ! file_exists( $fonts_file ) ) { 183 return array(); 184 } 185 186 $fonts_json = file_get_contents( $fonts_file ); 187 if ( false === $fonts_json ) { 188 return array(); 189 } 190 172 191 $fonts_array = json_decode( $fonts_json, true ); 173 174 // Format the variants array for easier use. 175 foreach ( $fonts_array as $key => $font ) { 176 $fonts_array[ $key ] = $font; 177 } 178 179 // Change the array key to the font's ID. 192 if ( null === $fonts_array ) { 193 return array(); 194 } 195 196 // Existing processing logic... 180 197 foreach ( $fonts_array as $font ) { 181 $id = trim( strtolower( str_replace( ' ', '-', $font['f'] ) ) );182 $fonts[ $id ] = $font;198 $id = trim( strtolower( str_replace( ' ', '-', $font['f'] ) ) ); 199 $fonts[ $id ] = $font; 183 200 $fonts[ $id ]['v'] = array_flip( $fonts[ $id ]['v'] ); 184 201 } -
olympus-google-fonts/tags/3.9.5/includes/gutenberg/class-ogf-gutenberg-filters.php
r3320024 r3323421 36 36 } 37 37 38 $fonts = new OGF_Fonts();38 $fonts = OGF_Fonts::get_instance(); 39 39 $fonts = $fonts->choices; 40 40 -
olympus-google-fonts/tags/3.9.5/includes/gutenberg/output-css.php
r3254070 r3323421 12 12 */ 13 13 function ogf_gutenberg_enqueue_fonts() { 14 $fonts = new OGF_Fonts();14 $fonts = OGF_Fonts::get_instance(); 15 15 16 16 if ( $fonts->has_google_fonts() ) { … … 28 28 global $current_screen; 29 29 $current_screen = get_current_screen(); 30 if ( ! method_exists( $current_screen, 'is_block_editor' ) || ! $current_screen->is_block_editor() ) {31 return;30 if ( ! $current_screen || ! method_exists( $current_screen, 'is_block_editor' ) || ! $current_screen->is_block_editor() ) { 31 return; 32 32 } 33 33 ?> -
olympus-google-fonts/tags/3.9.5/olympus-google-fonts.php
r3320024 r3323421 6 6 * Plugin URI: https://wordpress.org/plugins/olympus-google-fonts/ 7 7 * Description: The easiest to customize fonts in WordPress. Optimized for Speed. 1000+ font choices. Supports Google Fonts, Adobe Fonts and Upload Fonts. 8 * Version: 3.9. 48 * Version: 3.9.5 9 9 * Author: Fonts Plugin 10 10 * Author URI: https://fontsplugin.com/?utm_source=wporg&utm_medium=readme&utm_campaign=description -
olympus-google-fonts/tags/3.9.5/readme.txt
r3320024 r3323421 6 6 Tested up to: 6.8 7 7 License: GPLv2 or later 8 Stable tag: 3.9. 48 Stable tag: 3.9.5 9 9 10 10 The easiest to customize fonts in WordPress. Optimized for Speed. 1000+ font choices. Supports Google Fonts, Adobe Fonts and Upload Fonts. -
olympus-google-fonts/trunk/admin/class-ogf-upload-fonts-screen.php
r3100693 r3323421 97 97 $parent_file = $this->parent_menu_slug; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited 98 98 } 99 if ( get_current_screen()->id != 'edit-' . OGF_Fonts_Taxonomy::$taxonomy_slug ) { 99 $screen = get_current_screen(); 100 if ( ! $screen || $screen->id != 'edit-' . OGF_Fonts_Taxonomy::$taxonomy_slug ) { 100 101 return; 101 102 } … … 118 119 public function manage_columns( $columns ) { 119 120 $screen = get_current_screen(); 121 if ( ! $screen || $screen->id != 'edit-' . OGF_Fonts_Taxonomy::$taxonomy_slug ) { 122 return; 123 } 120 124 // If current screen is add new custom fonts screen. 121 125 if ( isset( $screen->base ) && 'edit-tags' == $screen->base ) { … … 417 421 418 422 /** 423 * Get the correct MIME type for a font file extension. 424 * 425 * @param string $extension The file extension. 426 * @return string The MIME type. 427 */ 428 private function get_font_mime_type( $extension ) { 429 switch ( $extension ) { 430 case 'ttf': 431 $php_7_ttf_mime_type = PHP_VERSION_ID >= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf'; 432 return PHP_VERSION_ID >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type; 433 434 case 'otf': 435 return 'application/vnd.ms-opentype'; 436 437 case 'woff': 438 return PHP_VERSION_ID >= 80112 ? 'font/woff' : 'application/font-woff'; 439 440 case 'woff2': 441 return PHP_VERSION_ID >= 80112 ? 'font/woff2' : 'application/font-woff2'; 442 443 default: 444 return ''; 445 } 446 } 447 448 /** 419 449 * Add WOFF and WOFF2 to the allowed mime types. 420 450 * … … 423 453 */ 424 454 public function add_to_allowed_mimes( $mimes ) { 425 426 $php_7_ttf_mime_type = PHP_VERSION_ID >= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf'; 427 428 $mimes['otf'] = 'application/vnd.ms-opentype'; 429 $mimes['ttf'] = PHP_VERSION_ID >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type; 430 $mimes['woff'] = PHP_VERSION_ID >= 80112 ? 'font/woff' : 'application/font-woff'; 431 $mimes['woff2'] = PHP_VERSION_ID >= 80112 ? 'font/woff2' : 'application/font-woff2'; 455 $mimes['otf'] = $this->get_font_mime_type( 'otf' ); 456 $mimes['ttf'] = $this->get_font_mime_type( 'ttf' ); 457 $mimes['woff'] = $this->get_font_mime_type( 'woff' ); 458 $mimes['woff2'] = $this->get_font_mime_type( 'woff2' ); 432 459 433 460 return $mimes; … … 445 472 */ 446 473 public function update_mime_types( $defaults, $file, $filename ) { 447 if ( 'ttf' === pathinfo( $filename, PATHINFO_EXTENSION ) ) {448 $defaults['type'] = 'application/x-font-ttf'; 449 $defaults['ext'] = 'ttf';450 }451 452 if ( 'otf' === pathinfo( $filename, PATHINFO_EXTENSION) ) {453 $defaults['type'] = 'application/x-font-otf';454 $defaults['ext'] = 'otf';474 $extension = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) ); 475 476 // Get the MIME type using the same logic as add_to_allowed_mimes(). 477 $mime_type = $this->get_font_mime_type( $extension ); 478 479 if ( ! empty( $mime_type ) ) { 480 $defaults['type'] = $mime_type; 481 $defaults['ext'] = $extension; 455 482 } 456 483 -
olympus-google-fonts/trunk/assets/js/uploadFonts.js
r3100693 r3323421 51 51 file_frame.open(); 52 52 }); 53 var file_frame;54 window.inputWrapper = '';55 53 }, 56 54 } -
olympus-google-fonts/trunk/blocks/src/google-fonts/edit.js
r3221683 r3323421 276 276 }, 277 277 { 278 value: ' 500',278 value: '600', 279 279 label: __('Semi Bold', 'olympus-google-fonts' ), 280 280 }, -
olympus-google-fonts/trunk/changelog.txt
r3320024 r3323421 1 = 3.9.5 = 2 3 * Fix error when use Blubrry podcast plugin 4 * Fix null reference errors when get_current_screen() returns null 5 * Fix memory leak by implementing singleton pattern for font loading with backward compatibility 6 * Fix PHP 8.0+ compatibility by replacing str_starts_with() with strpos() 7 * Fix inconsistent MIME type handling for font file uploads 8 1 9 = 3.9.4 = 2 10 -
olympus-google-fonts/trunk/class-olympus-google-fonts.php
r3320024 r3323421 39 39 public function constants() { 40 40 if ( ! defined( 'OGF_VERSION' ) ) { 41 define( 'OGF_VERSION', '3.9. 4' );41 define( 'OGF_VERSION', '3.9.5' ); 42 42 } 43 43 … … 134 134 */ 135 135 public function enqueue() { 136 $fonts = new OGF_Fonts();136 $fonts = OGF_Fonts::get_instance(); 137 137 138 138 if ( ! $fonts->has_google_fonts() ) { … … 165 165 } 166 166 167 $fonts = new OGF_Fonts();167 $fonts = OGF_Fonts::get_instance(); 168 168 169 169 // If no Google Fonts are being used we don't need this. -
olympus-google-fonts/trunk/includes/class-ogf-classic-editor.php
r3243818 r3323421 50 50 } 51 51 52 $this->ogf_fonts = new OGF_Fonts();52 $this->ogf_fonts = OGF_Fonts::get_instance(); 53 53 $this->system_fonts = ogf_system_fonts(); 54 54 $this->custom_fonts = ogf_custom_fonts(); -
olympus-google-fonts/trunk/includes/class-ogf-clear-cache.php
r3100693 r3323421 90 90 */ 91 91 public function clear() { 92 $fonts = new OGF_Fonts();92 $fonts = OGF_Fonts::get_instance(); 93 93 94 94 if ( $fonts->has_google_fonts() ) { -
olympus-google-fonts/trunk/includes/class-ogf-fonts.php
r3100693 r3323421 27 27 28 28 /** 29 * Let's get started. 29 * Single instance of the class. 30 * 31 * @var OGF_Fonts|null 32 */ 33 private static $instance = null; 34 35 /** 36 * Get the singleton instance. 37 * 38 * @return OGF_Fonts 39 */ 40 public static function get_instance() { 41 if ( null === self::$instance ) { 42 self::$instance = new self(); 43 } 44 return self::$instance; 45 } 46 47 /** 48 * Constructor - made public for backward compatibility. 49 * External plugins/code can still use 'new OGF_Fonts()'. 30 50 */ 31 51 public function __construct() { 32 self::$google_fonts = ogf_fonts_array(); 52 // If this is not the singleton instance, just initialize normally for backward compatibility. 53 if ( null !== self::$instance && self::$instance !== $this ) { 54 // This is a separate instance for backward compatibility. 55 $this->initialize(); 56 return; 57 } 58 59 // This is the singleton instance. 60 $this->initialize(); 61 } 62 63 /** 64 * Initialize the font data and choices. 65 */ 66 private function initialize() { 67 // Only load fonts array if not already loaded. 68 if ( empty( self::$google_fonts ) ) { 69 self::$google_fonts = ogf_fonts_array(); 70 } 33 71 $this->get_choices(); 72 } 73 74 /** 75 * Prevent cloning of the instance. 76 */ 77 private function __clone() {} 78 79 /** 80 * Prevent unserialization of the instance. 81 * 82 * @throws Exception When attempting to unserialize. 83 */ 84 public function __wakeup() { 85 throw new Exception( 'Cannot unserialize singleton' ); 34 86 } 35 87 … … 78 130 */ 79 131 public function get_font_weights( $font_id ) { 132 // Check if font exists in the array. 133 if ( ! array_key_exists( $font_id, self::$google_fonts ) ) { 134 return array(); 135 } 136 137 // Check if the font has variants data. 138 if ( ! isset( self::$google_fonts[ $font_id ]['v'] ) ) { 139 return array(); 140 } 141 80 142 $weights = self::$google_fonts[ $font_id ]['v']; 81 143 … … 95 157 */ 96 158 public function get_font_subsets( $font_id ) { 159 // Check if font exists in the array. 160 if ( ! array_key_exists( $font_id, self::$google_fonts ) ) { 161 return array(); 162 } 163 164 // Check if the font has subsets data. 165 if ( ! isset( self::$google_fonts[ $font_id ]['s'] ) ) { 166 return array(); 167 } 168 97 169 $subsets = self::$google_fonts[ $font_id ]['s']; 98 170 … … 113 185 */ 114 186 public function get_font_name( $font_id ) { 115 if ( array_key_exists( $font_id, self::$google_fonts ) ) {187 if ( array_key_exists( $font_id, self::$google_fonts ) && isset( self::$google_fonts[ $font_id ]['f'] ) ) { 116 188 return self::$google_fonts[ $font_id ]['f']; 117 189 } else { … … 203 275 if ( false === ( $external_font_css ) ) { 204 276 // It wasn't there, so regenerate the data and save the transient. 205 $external_font_css = '/* Cached: ' . date( 'F j, Y \a\t g:ia' ) . ' */' . PHP_EOL;277 $external_font_css = '/* Cached: ' . gmdate( 'F j, Y \a\t g:ia' ) . ' */' . PHP_EOL; 206 278 $external_font_css .= $this->get_remote_url_contents( $url ) . PHP_EOL; 207 279 set_transient( 'ogf_external_font_css_' . $url_to_id, $external_font_css, DAY_IN_SECONDS ); -
olympus-google-fonts/trunk/includes/class-ogf-typekit.php
r3128267 r3323421 138 138 */ 139 139 public function css_styles() { 140 if ( get_current_screen()->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 140 $screen = get_current_screen(); 141 if ( ! $screen || $screen->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 141 142 return; 142 143 } … … 159 160 160 161 // Only perform action on the Fonts Plugin Typekit Page. 161 if ( get_current_screen()->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 162 $screen = get_current_screen(); 163 if ( ! $screen || $screen->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 162 164 return; 163 165 } … … 231 233 public function manage_kits() { 232 234 // Only perform action on the Fonts Plugin Typekit Page. 233 if ( get_current_screen()->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 235 $screen = get_current_screen(); 236 if ( ! $screen || $screen->id !== 'fonts-plugin_page_fonts-plugin-typekit' ) { 234 237 return; 235 238 } -
olympus-google-fonts/trunk/includes/customizer/output-css.php
r3254070 r3323421 208 208 $cache_key = 'ogf_font_stack_' . md5( $font_id ); 209 209 $cached_stack = wp_cache_get( $cache_key ); 210 211 210 if ( $cached_stack !== false ) { 212 211 return $cached_stack; … … 216 215 $stack = ''; 217 216 218 if ( str_starts_with( $font_id, 'sf-' ) !== false) {217 if ( 0 === strpos( $font_id, 'sf-' ) ) { 219 218 $system_fonts = ogf_system_fonts(); 220 219 $font_id = str_replace( 'sf-', '', $font_id ); … … 223 222 $stack = $system_fonts[ $font_id ]['stack']; 224 223 } 225 } elseif ( str_starts_with( $font_id, 'cf-' ) !== false) {224 } elseif ( 0 === strpos( $font_id, 'cf-' ) ) { 226 225 $custom_fonts = ogf_custom_fonts(); 227 226 $font_id = str_replace( 'cf-', '', $font_id ); … … 235 234 $stack = '"' . $font . '"'; 236 235 } 237 } elseif ( str_starts_with( $font_id, 'tk-' ) !== false) {236 } elseif ( 0 === strpos( $font_id, 'tk-' ) ) { 238 237 $typekit_fonts = ogf_typekit_fonts(); 239 238 … … 250 249 251 250 // Cache the result. 252 wp_cache_set( $cache_key, $stack, 'ogf_font_stacks', HOUR_IN_SECONDS ); 253 251 wp_cache_set( $cache_key, $stack, 'ogf_font_stacks', HOUR_IN_SECONDS ); 254 252 // Allow filtering of the final stack. 255 253 return apply_filters( "ogf_{$font_id}_stack", $stack ); -
olympus-google-fonts/trunk/includes/customizer/settings.php
r3100693 r3323421 298 298 ); 299 299 300 $fonts = new OGF_Fonts();300 $fonts = OGF_Fonts::get_instance(); 301 301 $subsets = array(); 302 302 -
olympus-google-fonts/trunk/includes/functions.php
r3254070 r3323421 156 156 157 157 /** 158 * Get the OGF_Fonts singleton instance. 159 * 160 * @return OGF_Fonts The singleton instance. 161 */ 162 function ogf_get_fonts_instance() { 163 return OGF_Fonts::get_instance(); 164 } 165 166 167 168 /** 158 169 * Return an array of all available Google Fonts. 159 170 * … … 167 178 } 168 179 169 $fonts_json = file_get_contents( OGF_DIR_PATH . '/blocks/src/google-fonts/fonts.json' ); 170 171 // Change the object to a multidimensional array. 180 $fonts_file = OGF_DIR_PATH . '/blocks/src/google-fonts/fonts.json'; 181 182 if ( ! file_exists( $fonts_file ) ) { 183 return array(); 184 } 185 186 $fonts_json = file_get_contents( $fonts_file ); 187 if ( false === $fonts_json ) { 188 return array(); 189 } 190 172 191 $fonts_array = json_decode( $fonts_json, true ); 173 174 // Format the variants array for easier use. 175 foreach ( $fonts_array as $key => $font ) { 176 $fonts_array[ $key ] = $font; 177 } 178 179 // Change the array key to the font's ID. 192 if ( null === $fonts_array ) { 193 return array(); 194 } 195 196 // Existing processing logic... 180 197 foreach ( $fonts_array as $font ) { 181 $id = trim( strtolower( str_replace( ' ', '-', $font['f'] ) ) );182 $fonts[ $id ] = $font;198 $id = trim( strtolower( str_replace( ' ', '-', $font['f'] ) ) ); 199 $fonts[ $id ] = $font; 183 200 $fonts[ $id ]['v'] = array_flip( $fonts[ $id ]['v'] ); 184 201 } -
olympus-google-fonts/trunk/includes/gutenberg/class-ogf-gutenberg-filters.php
r3320024 r3323421 36 36 } 37 37 38 $fonts = new OGF_Fonts();38 $fonts = OGF_Fonts::get_instance(); 39 39 $fonts = $fonts->choices; 40 40 -
olympus-google-fonts/trunk/includes/gutenberg/output-css.php
r3254070 r3323421 12 12 */ 13 13 function ogf_gutenberg_enqueue_fonts() { 14 $fonts = new OGF_Fonts();14 $fonts = OGF_Fonts::get_instance(); 15 15 16 16 if ( $fonts->has_google_fonts() ) { … … 28 28 global $current_screen; 29 29 $current_screen = get_current_screen(); 30 if ( ! method_exists( $current_screen, 'is_block_editor' ) || ! $current_screen->is_block_editor() ) {31 return;30 if ( ! $current_screen || ! method_exists( $current_screen, 'is_block_editor' ) || ! $current_screen->is_block_editor() ) { 31 return; 32 32 } 33 33 ?> -
olympus-google-fonts/trunk/olympus-google-fonts.php
r3320024 r3323421 6 6 * Plugin URI: https://wordpress.org/plugins/olympus-google-fonts/ 7 7 * Description: The easiest to customize fonts in WordPress. Optimized for Speed. 1000+ font choices. Supports Google Fonts, Adobe Fonts and Upload Fonts. 8 * Version: 3.9. 48 * Version: 3.9.5 9 9 * Author: Fonts Plugin 10 10 * Author URI: https://fontsplugin.com/?utm_source=wporg&utm_medium=readme&utm_campaign=description -
olympus-google-fonts/trunk/readme.txt
r3320024 r3323421 6 6 Tested up to: 6.8 7 7 License: GPLv2 or later 8 Stable tag: 3.9. 48 Stable tag: 3.9.5 9 9 10 10 The easiest to customize fonts in WordPress. Optimized for Speed. 1000+ font choices. Supports Google Fonts, Adobe Fonts and Upload Fonts.
Note: See TracChangeset
for help on using the changeset viewer.