the translated default. * * @return array */ public static function defaults(): array { return [ 'label' => __('Add a tip', 'dankon'), 'description' => __('Support our team, every tip is appreciated. Choose an amount or skip.', 'dankon'), ]; } /** * Fill every empty text key with its translated default. * * Applied on the way OUT, where the string is about to be shown, and never * on the way in: writing the resolved text back to the option would freeze * one language into the database, which is the bug this class exists to fix. * * @param array $settings * @return array */ public static function apply(array $settings): array { foreach (self::defaults() as $key => $text) { if (trim((string) ($settings[$key] ?? '')) === '') { $settings[$key] = $text; } } return $settings; } }