Skip to content

Commit 03c4709

Browse files
committed
fix(e2e): load text domain at init priority 1 and disable WP_DEBUG_DISPLAY
In WP 6.7+, register_block_type() translates block.json strings via __() at init priority 10, before load_plugin_textdomain() ran (also priority 10, but registered later). This triggered the JIT textdomain notice which output text before headers, breaking cookie-based login in E2E tests. Moving load_plugin_textdomain to priority 1 ensures the domain is loaded before any __() calls during block registration. WP_DEBUG_DISPLAY: false prevents any future PHP notices from reaching the browser output stream, keeping wp-login.php headers intact in wp-env. Made-with: Cursor
1 parent f42dcc4 commit 03c4709

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

.wp-env.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
"env": {
77
"development": {
88
"port": 8888,
9-
"phpVersion": "8.1"
9+
"phpVersion": "8.1",
10+
"config": {
11+
"WP_DEBUG": true,
12+
"WP_DEBUG_DISPLAY": false,
13+
"WP_DEBUG_LOG": true
14+
}
1015
}
1116
}
1217
}

aldus.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,16 @@ function aldus_init(): void {
9090
require_once ALDUS_PATH . 'includes/admin-page.php';
9191
}
9292

93-
add_action( 'init', 'aldus_register_block' );
93+
// Load text domain at priority 1 so it is available before register_block_type()
94+
// (priority 10) translates block.json title/description via __() in WP 6.7+.
9495
add_action(
9596
'init',
9697
static function (): void {
9798
load_plugin_textdomain( 'aldus', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
98-
}
99+
},
100+
1
99101
);
102+
add_action( 'init', 'aldus_register_block' );
100103
add_action( 'rest_api_init', 'aldus_register_rest_routes' );
101104

102105
// Flush cached theme data whenever the active theme or Customizer settings change.

0 commit comments

Comments
 (0)