@@ -19,10 +19,12 @@ import {
19
19
} from '.' ;
20
20
import { joinPaths } from '@php-wasm/util' ;
21
21
import { logger } from '@php-wasm/logger' ;
22
+ import { removeURLScope } from '@php-wasm/scopes' ;
22
23
import {
23
24
getLoadedWordPressVersion ,
24
25
isSupportedWordPressVersion ,
25
26
} from './version-detect' ;
27
+ import { wpVersionToStaticAssetsDirectory } from '@wp-playground/wordpress-builds' ;
26
28
27
29
export type PhpIniOptions = Record < string , string > ;
28
30
export type Hook = ( php : PHP ) => void | Promise < void > ;
@@ -195,11 +197,6 @@ export async function bootWordPress(options: BootOptions) {
195
197
php . defineConstant ( 'WP_HOME' , options . siteUrl ) ;
196
198
php . defineConstant ( 'WP_SITEURL' , options . siteUrl ) ;
197
199
198
- // Run "before database" hooks to mount/copy more files in
199
- if ( options . hooks ?. beforeDatabaseSetup ) {
200
- await options . hooks . beforeDatabaseSetup ( php ) ;
201
- }
202
-
203
200
// @TODO Assert WordPress core files are in place
204
201
205
202
const remoteAssetListPath = joinPaths (
@@ -221,9 +218,13 @@ export async function bootWordPress(options: BootOptions) {
221
218
requestHandler
222
219
) ;
223
220
if ( isSupportedWordPressVersion ( loadedWordPressVersion ) ) {
224
- // TODO: Is this an absolute URI we can count on?
225
- const wpAssetBaseUrl = `/wp-${ loadedWordPressVersion } ` ;
226
- const listUrl = `${ wpAssetBaseUrl } /wordpress-remote-asset-paths` ;
221
+ const unscopedBaseUrl = removeURLScope (
222
+ new URL ( requestHandler . absoluteUrl )
223
+ ) ;
224
+ const wpStaticAssetsDir = wpVersionToStaticAssetsDirectory (
225
+ loadedWordPressVersion
226
+ ) ;
227
+ const listUrl = `${ unscopedBaseUrl . href } /${ wpStaticAssetsDir } /wordpress-remote-asset-paths` ;
227
228
try {
228
229
const remoteAssetPaths = await fetch ( listUrl ) . then ( ( res ) =>
229
230
res . text ( )
@@ -237,6 +238,11 @@ export async function bootWordPress(options: BootOptions) {
237
238
}
238
239
}
239
240
241
+ // Run "before database" hooks to mount/copy more files in
242
+ if ( options . hooks ?. beforeDatabaseSetup ) {
243
+ await options . hooks . beforeDatabaseSetup ( php ) ;
244
+ }
245
+
240
246
if ( options . sqliteIntegrationPluginZip ) {
241
247
await preloadSqliteIntegration (
242
248
php ,
0 commit comments