diff --git a/packages/playground/blueprints/src/lib/steps/apply-wordpress-patches/wp-content/mu-plugins/0-playground.php b/packages/playground/blueprints/src/lib/steps/apply-wordpress-patches/wp-content/mu-plugins/0-playground.php
index f6f345bb19..b5e89d1cf6 100644
--- a/packages/playground/blueprints/src/lib/steps/apply-wordpress-patches/wp-content/mu-plugins/0-playground.php
+++ b/packages/playground/blueprints/src/lib/steps/apply-wordpress-patches/wp-content/mu-plugins/0-playground.php
@@ -20,35 +20,57 @@ function () {
* makes it more clear that the feature is not yet supported.
*
* https://github.com/WordPress/wordpress-playground/issues/498
+ *
+ * Added styling to hide the Popular tags section of the Plugins page
+ * and the nonfunctional Try Again button (both Plugins and Themes) that's
+ * appended when the message is displayed.
+ *
+ * https://github.com/WordPress/wordpress-playground/issues/927
+ *
*/
+
+ add_action('admin_head', function () {
+ echo '';
+});
+
+add_action('init', 'networking_disabled');
+function networking_disabled() {
+ $networking_err_msg = '
Network access is an
experimental, opt-in feature, which means you need to enable it to allow Playground to access the Plugins/Themes directories.
+
There are two alternative methods to enable global networking support:
+
+ - Using the Query API: for example, https://playground.wordpress.net/?networking=yes; or
+
- Using the Blueprint API: add
"features": { "networking": true }
to the JSON file.
+
+
+ When browsing Playground as a standalone instance, you can enable networking via the settings panel: select the option "Network access (e.g. for browsing plugins)" and hit the "Apply changes" button.
+ Please note: This option is hidden when browsing Playground as an embedded iframe.
';
+ return $networking_err_msg;
+}
+
add_filter('plugins_api_result', function ($res) {
if ($res instanceof WP_Error) {
$res = new WP_Error(
'plugins_api_failed',
- 'Enable networking support in Playground settings to access the Plugins directory. Network access is an experimental, opt-in feature. If you don\'t want to use it, you can still upload plugins or install them using the Query API (e.g. ?plugin=coblocks).'
- );
+ networking_disabled()
+ );
}
return $res;
});
add_filter('gettext', function ($translation) {
- // There is no better hook for swapping the error message
- // on the themes page, unfortunately.
- global $pagenow;
-
- // Only change the message on /wp-admin/theme-install.php
- if ('theme-install.php' !== $pagenow) {
- return $translation;
- }
-
- 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 support forums.') {
- return 'Enable networking support in Playground settings to access the Themes directory. Network access is an experimental, opt-in feature. If you don\'t want to use it, you can still upload themes or install them using the Query API (e.g. ?theme=pendant).';
+ if( $GLOBALS['pagenow'] === 'theme-install.php') {
+ 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 support forums.') {
+ return networking_disabled();
+ }
}
return $translation;
});
-
-
/**
* Links with target="top" don't work in the playground iframe because of
* the sandbox attribute. What they really should be targeting is the
diff --git a/packages/playground/website/cypress/e2e/app.cy.ts b/packages/playground/website/cypress/e2e/app.cy.ts
index 4df908584a..9cdf16d338 100644
--- a/packages/playground/website/cypress/e2e/app.cy.ts
+++ b/packages/playground/website/cypress/e2e/app.cy.ts
@@ -65,7 +65,10 @@ describe('Query API', () => {
cy.visit('/?url=/wp-admin/plugin-install.php');
cy.wordPressDocument()
.find('.notice.error')
- .should('contain', 'Enable networking support in Playground');
+ .should(
+ 'contain',
+ 'Network access is an experimental, opt-in feature'
+ );
});
it('should enable networking when requested', () => {