= AGYL_DB_VERSION ) { return; } // Schema::install() stamps agyl_db_version itself on success and sets // agyl_schema_error on failure. If it could not create every table, // do NOT run data migrations or stamp the version — a constrained host // must be retried on the next request, never left silently half-built. if ( ! Schema::install() ) { return; } foreach ( $this->steps() as $version => $step ) { if ( $installed < $version ) { $step(); } } update_option( 'agyl_db_version', AGYL_DB_VERSION, false ); } /** * Data-migration steps keyed by the schema version that introduces them. * Runs in ascending order after dbDelta. * * @return array */ private function steps(): array { return array( // v9 (plugin 0.4.0): the brand default widget color changed to // indigo. Sites still on a previous DEFAULT get the new default; // any custom color the owner picked is left untouched. 9 => static function (): void { $widget = get_option( 'agyl_settings_widget', array() ); if ( ! is_array( $widget ) || empty( $widget['primary_color'] ) ) { return; } $old_defaults = array( '#3858e9', '#0a2a4e' ); if ( in_array( strtolower( (string) $widget['primary_color'] ), $old_defaults, true ) ) { $widget['primary_color'] = '#4f46e5'; update_option( 'agyl_settings_widget', $widget ); } }, ); } }