Skip to content

Commit dba74c2

Browse files
authoredFeb 17, 2025
Fix translation loaded too early (#124)
1 parent 1d7b87d commit dba74c2

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed
 

‎app/Features/MaintenanceMode.php

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ final class MaintenanceMode implements Hookable
2525
public function hook(Hook $hook): void
2626
{
2727
$hook->addFilter(Option::hook('sanitize:site_maintenance_args'), [$this, 'sanitizeArgsOption'], PHP_INT_MAX);
28+
$hook->addFilter(Option::hook('default:site_maintenance_args'), static function (): array {
29+
return [
30+
'headline' => __(
31+
'Under Maintenance 🚧',
32+
'syntatis-feature-flipper',
33+
),
34+
'message' => __(
35+
'We are currently performing some scheduled maintenance. We will be back as soon as possible.',
36+
'syntatis-feature-flipper',
37+
),
38+
];
39+
}, PHP_INT_MAX);
2840

2941
if (Option::get('site_access') !== 'maintenance') {
3042
return;

‎inc/settings/all.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@
148148
'message' => ['type' => 'string'],
149149
],
150150
])
151-
->withDefault([
152-
'headline' => __(
153-
'Under Maintenance 🚧',
154-
'syntatis-feature-flipper',
155-
),
156-
'message' => __(
157-
'We are currently performing some scheduled maintenance. We will be back as soon as possible.',
158-
'syntatis-feature-flipper',
159-
),
160-
]),
151+
/**
152+
* The default requires translatable string values for the `headline` and
153+
* `message` properties. The default value will be set via the filter.
154+
* Otherwise, it will throw an error due to the translations called
155+
* too early.
156+
*
157+
* @see app/Features/MaintenanceMode.php#L28
158+
* @see https://github.com/WordPress/WordPress/blob/master/wp-includes/l10n.php#L1371-L1380
159+
*/
160+
->withDefault(null),
161161

162162
// Site: Assets.
163163
(new Setting('emojis', 'boolean'))

0 commit comments

Comments
 (0)
Please sign in to comment.