Skip to content

Commit

Permalink
Noodling on multisites
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Dec 20, 2023
1 parent a54a69e commit e4e247c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/php-wasm/universal/src/lib/base-php.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export abstract class BasePHP implements IsomorphicLocalPHP {
}
}

defineConstant(key: string, value: string | number | null) {
defineConstant(key: string, value: string | boolean | number | null) {
let consts = {};
try {
consts = JSON.parse(
Expand Down
2 changes: 1 addition & 1 deletion packages/php-wasm/web/src/lib/web-php-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class WebPHPEndpoint implements IsomorphicLocalPHP {
}

/** @inheritDoc @php-wasm/web!WebPHP.defineConstant */
defineConstant(key: string, value: string | number | null): void {
defineConstant(key: string, value: string | boolean | number | null): void {
_private.get(this)!.php.defineConstant(key, value);
}

Expand Down
38 changes: 38 additions & 0 deletions packages/playground/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,44 @@ export async function startPlaygroundWeb({
await runBlueprintSteps(compiled, playground);
progressTracker.finish();

await playground.defineConstant('WP_ALLOW_MULTISITE', true);
await playground.defineConstant('DOMAIN_CURRENT_SITE', 'localhost:5400');
await playground.defineConstant(
'PATH_CURRENT_SITE',
new URL(await playground.absoluteUrl).pathname
);

const response = await playground.run({
code: `<?php
define( 'WP_ALLOW_MULTISITE', true );
define( 'WP_INSTALLING_NETWORK', true );
require '/wordpress/wp-load.php';
require '/wordpress/wp-admin/includes/plugin.php';
deactivate_plugins('wordpress-importer/wordpress-importer.php');
require '/wordpress/wp-admin/includes/network.php';
foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) {
$wpdb->$table = $prefixed_table;
}
require_once '/wordpress/wp-admin/includes/upgrade.php';
$result = install_network();
var_dump($result);
require_once '/wordpress/wp-admin/includes/upgrade.php';
$base = "${new URL(await playground.absoluteUrl).pathname}";
$result = populate_network( 1, "localhost:5400", sanitize_email( "[email protected]" ), wp_unslash( "My network!" ), $base, $subdomain_install = false );
var_dump($result);
`,
});
console.log(response.text);

await playground.defineConstant('MULTISITE', true);
await playground.defineConstant('SUBDOMAIN_INSTALL', false);
await playground.defineConstant('SITE_ID_CURRENT_SITE', 1);
await playground.defineConstant('BLOG_ID_CURRENT_SITE', 1);
console.log('defined');

return playground;
}

Expand Down

0 comments on commit e4e247c

Please sign in to comment.