the translated default. * * @return array */ public static function defaults(): array { return [ 'box_title' => __('Frequently bought together', 'bundaro'), 'add_label' => __('Add bundle to cart', 'bundaro'), 'fee_label' => __('Bundle discount', 'bundaro'), 'add_failed_text' => __('Some bundled products could not be added to the cart.', 'bundaro'), ]; } /** * 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; } }