@@ -7,16 +7,8 @@ import {
77 LatestSupportedWordPressVersion ,
88 SupportedWordPressVersions ,
99} from '@wp-playground/wordpress-builds' ;
10- import {
11- envPHP_to_loadMuPlugins ,
12- playgroundMuPlugin ,
13- wordPressRewriteRules ,
14- } from '@wp-playground/wordpress' ;
15- import {
16- PHPRequestHandler ,
17- proxyFileSystem ,
18- writeFiles ,
19- } from '@php-wasm/universal' ;
10+ import { wordPressRewriteRules } from '@wp-playground/wordpress' ;
11+ import { PHPRequestHandler } from '@php-wasm/universal' ;
2012import {
2113 SyncProgressCallback ,
2214 bindOpfs ,
@@ -28,13 +20,7 @@ import {
2820 unzip ,
2921} from '@wp-playground/blueprints' ;
3022
31- /** @ts -ignore */
32- import transportFetch from './playground-mu-plugin/playground-includes/wp_http_fetch.php?raw' ;
33- /** @ts -ignore */
34- import transportDummy from './playground-mu-plugin/playground-includes/wp_http_dummy.php?raw' ;
35- /** @ts -ignore */
36- import playgroundWebMuPlugin from './playground-mu-plugin/0-playground.php?raw' ;
37- import { joinPaths , randomString } from '@php-wasm/util' ;
23+ import { randomString } from '@php-wasm/util' ;
3824import {
3925 requestedWPVersion ,
4026 createPhp ,
@@ -169,37 +155,12 @@ export class PlaygroundWorkerEndpoint extends WebPHPEndpoint {
169155
170156const scopedSiteUrl = setURLScope ( wordPressSiteUrl , scope ) . toString ( ) ;
171157const requestHandler = new PHPRequestHandler ( {
172- phpFactory : async ( { isPrimary } ) => {
173- const php = await createPhp ( requestHandler ) ;
174- php . defineConstant ( 'SCOPED_SITE_PATH' , new URL ( scopedSiteUrl ) . pathname ) ;
175- if ( isPrimary ) {
176- php . writeFile (
177- '/internal/shared/preload/env.php' ,
178- envPHP_to_loadMuPlugins
179- ) ;
180- php . writeFile (
181- '/internal/shared/preload/phpinfo.php' ,
182- `<?php
183- // Render PHPInfo if the requested page is /phpinfo.php
184- if ( SCOPED_SITE_PATH . '/phpinfo.php' === $_SERVER['REQUEST_URI'] ) {
185- phpinfo();
186- exit;
187- }
188- `
189- ) ;
190- } else {
191- proxyFileSystem ( await requestHandler . getPrimaryPhp ( ) , php , [
192- '/tmp' ,
193- requestHandler . documentRoot ,
194- '/internal/shared' ,
195- ] ) ;
196- }
197- return php ;
198- } ,
158+ phpFactory : async ( { isPrimary } ) =>
159+ await createPhp ( requestHandler , scopedSiteUrl , isPrimary ) ,
199160 documentRoot : DOCROOT ,
200161 absoluteUrl : scopedSiteUrl ,
201162 rewriteRules : wordPressRewriteRules ,
202- } ) ;
163+ } ) as PHPRequestHandler < WebPHP > ;
203164const apiEndpoint = new PlaygroundWorkerEndpoint (
204165 requestHandler ,
205166 downloadMonitor ,
@@ -241,18 +202,6 @@ try {
241202 } ) ;
242203 }
243204
244- // Always install the playground mu-plugin, even if WordPress is loaded
245- // from the OPFS. This ensures:
246- // * The mu-plugin is always there, even when a custom WordPress directory
247- // is mounted.
248- // * The mu-plugin is always up to date.
249- await writeFiles ( primaryPhp , joinPaths ( '/internal/shared/mu-plugins' ) , {
250- '0-playground.php' : playgroundMuPlugin ,
251- '1-playground-web.php' : playgroundWebMuPlugin ,
252- 'playground-includes/wp_http_dummy.php' : transportDummy ,
253- 'playground-includes/wp_http_fetch.php' : transportFetch ,
254- } ) ;
255-
256205 if ( virtualOpfsDir ) {
257206 await bindOpfs ( {
258207 php : primaryPhp ,
0 commit comments