| @@ -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(); |
| @@ -21,13 +23,41 @@ | ||
| 21 | 23 | if ( ABLOCKS_VERSION !== $ablocks_version ) { |
| 22 | 24 | Settings::save_settings(); |
| 23 | 25 | $this->migrate_1_6_3( $ablocks_version ); |
| 24 | 26 | $this->migrate_1_8_0( $ablocks_version ); |
| 25 | - $this->migrate_1_9_0( $ablocks_version ); | |
| 26 | 27 | update_option( 'ablocks_version', ABLOCKS_VERSION ); |
| 27 | 28 | } |
| 28 | 29 | } |
| 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' ); | |
| 58 | + } | |
| 59 | + | |
| 30 | 60 | public function migrate_1_6_3( $version ) { |
| 31 | 61 | if ( version_compare( $version, '1.6.3', '<=' ) ) { |
| 32 | 62 | add_option( 'ablocks_has_required_block_attribute_migration', '1.6.3' ); |
| 33 | 63 | // Delete Old Table |
| @@ -41,17 +71,10 @@ | ||
| 41 | 71 | public function migrate_1_8_0( $version ) { |
| 42 | 72 | if ( version_compare( $version, '1.8.0', '<=' ) ) { |
| 43 | 73 | global $wpdb; |
| 44 | 74 | $table_name = $wpdb->prefix . ABLOCKS_PLUGIN_SLUG . '_form_entries'; |
| 45 | - $wpdb->query( "ALTER TABLE {$table_name} MODIFY post_id VARCHAR(100) NULL" ); | |
| 46 | - } | |
| 47 | - } | |
| 48 | - | |
| 49 | - public function migrate_1_9_0( $version ) { | |
| 50 | - if ( version_compare( $version, '1.9.0', '<=' ) ) { | |
| 51 | - $saved_addons = (array) json_decode( get_option( ABLOCKS_ADDONS_SETTINGS_NAME ), true ); | |
| 52 | - $saved_addons[ 'theme-builder' ] = true; | |
| 53 | - update_option( ABLOCKS_ADDONS_SETTINGS_NAME, wp_json_encode( $saved_addons ) ); | |
| 75 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 76 | + $wpdb->query( "ALTER TABLE `{$table_name}` MODIFY `post_id` VARCHAR(100) NULL" ); | |
| 54 | 77 | } |
| 55 | 78 | } |
| 56 | 79 | |
| 57 | 80 | public function update_attributes_backward_compatibility( $block ) { |