| @@ -15,8 +15,10 @@ | ||
| 15 | 15 | add_filter( 'render_block_data', array( $self, 'update_attributes_backward_compatibility' ) ); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function run_migration() { |
| 19 | + $this->migrate_font_stack(); | |
| 20 | + | |
| 19 | 21 | $ablocks_version = get_option( 'ablocks_version' ); |
| 20 | 22 | // Save Version Number, flash role management and save permalink |
| 21 | 23 | if ( ABLOCKS_VERSION !== $ablocks_version ) { |
| 22 | 24 | Settings::save_settings(); |
| @@ -23,8 +25,37 @@ | ||
| 23 | 25 | $this->migrate_1_6_3( $ablocks_version ); |
| 24 | 26 | $this->migrate_1_8_0( $ablocks_version ); |
| 25 | 27 | update_option( 'ablocks_version', ABLOCKS_VERSION ); |
| 26 | 28 | } |
| 29 | + } | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * font-family declarations are now emitted as full stacks (quoted family + | |
| 33 | + * metric fallback + generic) instead of a bare family name. | |
| 34 | + * | |
| 35 | + * Block CSS is cached in generated files and the global CSS variables live in | |
| 36 | + * a transient, so both hold the old single-name output until something forces | |
| 37 | + * a rebuild. Clear them once so existing pages pick up the new stacks without | |
| 38 | + * anyone having to re-save every page. | |
| 39 | + */ | |
| 40 | + public function migrate_font_stack() { | |
| 41 | + if ( get_option( 'ablocks_font_stack_migrated' ) ) { | |
| 42 | + return; | |
| 43 | + } | |
| 44 | + | |
| 45 | + // Deleting generated files needs WP_Filesystem; keep that out of visitor | |
| 46 | + // requests. The first admin page load after the update does the work. | |
| 47 | + if ( ! is_admin() && ! ( defined( 'WP_CLI' ) && WP_CLI ) ) { | |
| 48 | + return; | |
| 49 | + } | |
| 50 | + | |
| 51 | + ( new \ABlocks\Classes\FileUpload() )->delete_files(); | |
| 52 | + delete_transient( 'ablocks_global_css_vars' ); | |
| 53 | + // Force a rebuild of the template/part/theme-builder font set, which did | |
| 54 | + // not exist before this release. | |
| 55 | + \ABlocks\Classes\FontCollector::flush_site_fonts(); | |
| 56 | + | |
| 57 | + update_option( 'ablocks_font_stack_migrated', '1' ); | |
| 27 | 58 | } |
| 28 | 59 | |
| 29 | 60 | public function migrate_1_6_3( $version ) { |
| 30 | 61 | if ( version_compare( $version, '1.6.3', '<=' ) ) { |