From 6eb7b2c4e3f580a4fb5014193cdca57fbcf0fecb Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Tue, 22 Apr 2025 00:40:59 +0100 Subject: [PATCH] Completely revise WordPress Playground multisite blueprint with manual setup approach --- .wiki/Playground-Testing.md | 4 ++-- .wiki/Testing.md | 2 +- playground/multisite-blueprint.json | 31 +++++++++++++++++++++++++++-- playground/multisite.html | 2 +- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.wiki/Playground-Testing.md b/.wiki/Playground-Testing.md index db644be..b50372f 100644 --- a/.wiki/Playground-Testing.md +++ b/.wiki/Playground-Testing.md @@ -17,7 +17,7 @@ The easiest way to test our plugin with WordPress Playground is to use the onlin 1. Single site testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/blueprint.json&_t=4) -2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=12) +2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=13) These links will automatically set up WordPress with our plugin installed and activated. @@ -32,7 +32,7 @@ To run tests with WordPress Playground: 1. Open the appropriate WordPress Playground link: - [Single site](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/blueprint.json&_t=4) - - [Multisite](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=12) + - [Multisite](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=13) 2. Test the plugin manually in the browser diff --git a/.wiki/Testing.md b/.wiki/Testing.md index 2bc7fad..a62c9dc 100644 --- a/.wiki/Testing.md +++ b/.wiki/Testing.md @@ -106,7 +106,7 @@ The easiest way to test our plugin with WordPress Playground is to use the onlin 1. Single site testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/blueprint.json&_t=4) -2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=12) +2. Multisite testing: [Open in WordPress Playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/wpallstars/wp-plugin-starter-template-for-ai-coding/feature/testing-framework/playground/multisite-blueprint.json&_t=13) These links will automatically set up WordPress with a sample plugin installed and activated. diff --git a/playground/multisite-blueprint.json b/playground/multisite-blueprint.json index 00d35a6..0f8dedf 100644 --- a/playground/multisite-blueprint.json +++ b/playground/multisite-blueprint.json @@ -1,16 +1,39 @@ { - "landingPage": "/wp-admin/network/", + "landingPage": "/wp-admin/", "login": true, "preferredVersions": { "php": "8.0", "wp": "latest" }, "steps": [ + { + "step": "defineWpConfig", + "name": "WP_DEBUG", + "value": true + }, + { + "step": "defineWpConfig", + "name": "WP_DEBUG_LOG", + "value": true + }, + { + "step": "defineWpConfig", + "name": "WP_DEBUG_DISPLAY", + "value": false + }, + { + "step": "runPHP", + "code": " 'WordPress Multisite',\n 'subdomain_install' => false,\n 'domain' => 'localhost',\n 'path' => '/',\n 'email' => 'admin@example.com'\n];\n\nupdate_option('admin_email', $network_data['email']);\n\ntry {\n error_log('Running wp_install_network()...');\n wp_install_network($network_data);\n error_log('Network setup completed successfully');\n} catch (Exception $e) {\n error_log('Network setup error: ' . $e->getMessage());\n}\n" + }, { "step": "defineWpConfig", "name": "MULTISITE", @@ -43,7 +66,7 @@ }, { "step": "runPHP", - "code": "get_error_message());\n die('Network installation failed');\n }\n // Populate network tables\n populate_network(1, 'localhost', '/', get_option('admin_email'), 'WordPress Multisite', '', false);\n}\n\n// Create a test subsite\n$domain = 'localhost';\n$path = '/testsite/';\n$title = 'Test Subsite';\n$user_id = 1;\n\nif (!function_exists('get_site_by_path')) {\n require_once('/wordpress/wp-includes/ms-blogs.php');\n}\n\nif (!get_site_by_path($domain, $path)) {\n $blog_id = wpmu_create_blog($domain, $path, $title, $user_id);\n if (is_wp_error($blog_id)) {\n error_log('Subsite creation error: ' . $blog_id->get_error_message());\n die('Subsite creation failed');\n } else {\n error_log('Created subsite with ID: ' . $blog_id);\n }\n} else {\n error_log('Subsite already exists');\n}\n" + "code": "get_results('SHOW TABLES LIKE \\'' . $wpdb->prefix . 'site\\';');\nerror_log('Multisite tables found: ' . count($tables));\n\nif (is_multisite()) {\n error_log('Creating test subsite...');\n $domain = 'localhost';\n $path = '/testsite/';\n $title = 'Test Subsite';\n $user_id = 1;\n\n if (!function_exists('get_site_by_path')) {\n require_once('/wordpress/wp-includes/ms-blogs.php');\n }\n\n if (!get_site_by_path($domain, $path)) {\n $blog_id = wpmu_create_blog($domain, $path, $title, $user_id);\n if (is_wp_error($blog_id)) {\n error_log('Subsite creation error: ' . $blog_id->get_error_message());\n } else {\n error_log('Created subsite with ID: ' . $blog_id);\n }\n } else {\n error_log('Subsite already exists');\n }\n}\n" }, { "step": "installPlugin", @@ -51,6 +74,10 @@ "resource": "wordpress.org/plugins", "slug": "coblocks" } + }, + { + "step": "runPHP", + "code": " - +