You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browser: Disable the network support by default and add a UI control to enable it (#812)
Disables the network support by default and adds a UI control to
enable it.
Why?
#724 introduced
support for wp_safe_remote_get() request and enabled it by default on
playground.wordpress.net. The problem is, all the requests block
rendering of WordPress pages and noticeably slow down the site. Let's
disable it by default for a lightweight user experience, and then add an
easy way to enable it, for example in the configuration modal.
Closes#755
## Testing Instructions
* Go to http://localhost:5400/website-server/?url=/wp-admin/plugin-install.php
* Confirm the plugins aren't loaded and you see a communicative error message
* Go to the settings modal
* Enable the network support
* Confirm the plugins are loaded now
<img width="1121" alt="CleanShot 2023-11-27 at 17 10 45@2x"
src="https://github.com/WordPress/wordpress-playground/assets/205419/ea95b783-d7a1-45c6-ab95-90b5c8ec6ce4">
|`networking`|`yes` or `no`| Enables or disables the networking support for Playground. Defaults to `yes`|
30
+
|`networking`|`yes` or `no`| Enables or disables the networking support for Playground. Defaults to `no`|
31
31
|`plugin`|| Installs the specified plugin. Use the plugin name from the plugins directory URL, e.g. for a URL like `https://wordpress.org/plugins/wp-lazy-loading/`, the plugin name would be `wp-lazy-loading`. You can pre-install multiple plugins by saying `plugin=coblocks&plugin=wp-lazy-loading&…`. Installing a plugin automatically logs the user in as an admin |
32
32
|`theme`|| Installs the specified theme. Use the theme name from the themes directory URL, e.g. for a URL like `https://wordpress.org/themes/disco/`, the theme name would be `disco`. Installing a theme automatically logs the user in as an admin |
33
33
|`url`|`/wp-admin/`| Load the specified initial page displaying WordPress |
Copy file name to clipboardExpand all lines: packages/docs/site/docs/09-blueprints-api/03-data-format.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,4 +63,4 @@ The `phpExtensionBundles` property is an array of PHP extension bundles to load.
63
63
64
64
The `features` property is used to enable or disable certain features of the Playground. It can contain the following properties:
65
65
66
-
-`networking`: Defaults to `true`. Enables or disables the networking support for Playground. If enabled, `wp_safe_remote_get` and similar WordPress functions will actually use `fetch()` to make HTTP requests. If disabled, they will immediately fail instead.
66
+
-`networking`: Defaults to `false`. Enables or disables the networking support for Playground. If enabled, `wp_safe_remote_get` and similar WordPress functions will actually use `fetch()` to make HTTP requests. If disabled, they will immediately fail instead.
Copy file name to clipboardExpand all lines: packages/docs/site/docs/11-architecture/02-wasm-php-overview.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,4 +20,4 @@ When it comes to networking, WebAssembly programs are limited to calling JavaScr
20
20
21
21
In Node.js, the answer involves a WebSocket to TCP socket proxy, [Asyncify](https://emscripten.org/docs/porting/asyncify.html), and patching deep PHP internals like php_select. It's complex, but there's a reward. The Node.js-targeted PHP build can request web APIs, install composer packages, and even connect to a MySQL server.
22
22
23
-
In the browser, networking is not supported yet. Initiating a HTTPS connection involves opening a raw TCP socket which is not possible in the browser. There is an [open GitHub issue](https://github.com/WordPress/wordpress-playground/issues/85) that explores possible ways of addressing this problem.
23
+
In the browser, networking is supported to a limited extent. Network calls initiated using `wp_safe_remote_get`, like the ones in the plugin directory or the font library, are translated into `fetch()` calls and succeed if the remote server sends the correct CORS headers. However, a full support for arbitrary HTTPS connection involves opening a raw TCP socket which is not possible in the browser. There is an [open GitHub issue](https://github.com/WordPress/wordpress-playground/issues/85) that explores possible ways of addressing this problem.
Copy file name to clipboardExpand all lines: packages/playground/blueprints/src/lib/steps/apply-wordpress-patches/wp-content/mu-plugins/2-nice-error-messages-for-plugins-and-themes-directories.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@
12
12
if($resinstanceof WP_Error) {
13
13
$res = newWP_Error(
14
14
'plugins_api_failed',
15
-
'Playground <a href="https://github.com/WordPress/wordpress-playground/issues/85">does not yet support</a> connecting to the plugin directory yet. You can still upload plugins or install them using the <a href="https://wordpress.github.io/wordpress-playground/query-api">Query API</a> (e.g. ?plugin=coblocks).'
15
+
'Enable networking support in Playground settings to access the Plugins directory. Network access is an <a href="https://github.com/WordPress/wordpress-playground/issues/85">experimental, opt-in feature</a>. If you don\'t want to use it, you can still upload plugins or install them using the <a href="https://wordpress.github.io/wordpress-playground/query-api">Query API</a> (e.g. ?plugin=coblocks).'
16
16
);
17
17
}
18
18
return$res;
@@ -29,7 +29,7 @@
29
29
}
30
30
31
31
if($translation === 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.') {
32
-
return'Playground <a href="https://github.com/WordPress/wordpress-playground/issues/85">does not yet support</a> connecting to the themes directory yet. You can still upload a theme or install it using the <a href="https://wordpress.github.io/wordpress-playground/query-api">Query API</a> (e.g. ?theme=pendant).';
32
+
return'Enable networking support in Playground settings to access the Themes directory. Network access is an <a href="https://github.com/WordPress/wordpress-playground/issues/85">experimental, opt-in feature</a>. If you don\'t want to use it, you can still upload themes or install them using the <a href="https://wordpress.github.io/wordpress-playground/query-api">Query API</a> (e.g. ?theme=pendant).';
0 commit comments