wordpress-playground icon indicating copy to clipboard operation
wordpress-playground copied to clipboard

Cannot install WP language through WP CLI - CORS issue

Open vyskoczilova opened this issue 1 year ago • 2 comments

Since one of my plugins allows you to switch between different locales in the admin I wanted to simply install them through WP CLI:

{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"landingPage": "\/wp-admin\/index.php",
	"preferredVersions": {
		"php": "8.0",
		"wp": "latest"
	},
	"phpExtensionBundles": ["kitchen-sink"],
	"features": {
		"networking": true
	},
	"steps": [
		{
			"step": "installPlugin",
			"pluginZipFile": {
				"resource": "wordpress.org/plugins",
				"slug": "simple-admin-language-change"
			},
			"options": {
				"activate": true
			}
		},
		{
			"step": "wp-cli",
			"command": "wp language core install fr_FR"
		},
		{
			"step": "wp-cli",
			"command": "wp language core install de_DE"
		},
		{
			"step": "wp-cli",
			"command": "wp language core install cs_CZ"
		},
		{
			"step": "wp-cli",
			"command": "wp language core install ar"
		},
		{
			"step": "login",
			"username": "admin",
			"password": "password"
		}
	]
}

But CORS forbid this:

image

vyskoczilova avatar Apr 05 '24 13:04 vyskoczilova

CC @dd32 – can we relax CORS for translations?

adamziel avatar Apr 09 '24 11:04 adamziel

@adamziel Escalated to Systems: https://make.wordpress.org/systems/2024/04/10/enable-cors-for-core-translation-downloads/

dd32 avatar Apr 10 '24 01:04 dd32

This seems to be done on June 5th 2024: https://make.wordpress.org/systems/2024/04/10/enable-cors-for-core-translation-downloads/#comment-2252

But for https://playground.wordpress.net/ I'm still not able to switch locales. The UI is missing completely on Settings -> General and in the profile there is only "English (US)" listed.

Is this hidden because of the former limitation? If yes, could this be showed again now, after the CORS issue is solved?

Zodiac1978 avatar Jun 14 '24 09:06 Zodiac1978

This seems to work now, but networking does need to be enabled.

This playground demo seems to work for me:

https://playground.wordpress.net/#{%22preferredVersions%22:{%22php%22:%228.0%22,%22wp%22:%226.5%22},%22phpExtensionBundles%22:[%22kitchen-sink%22],%22features%22:{%22networking%22:true},%22landingPage%22:%22/wp-admin/options-general.php%22,%22steps%22:[{%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22}]}

dd32 avatar Jun 17 '24 05:06 dd32

Thank you very much @dd32 - confirmed! It is working for me too with networking enabled.

But there is still one CORS error in my browser console for this link: https://api.wordpress.org/themes/update-check/1.1/ on the Options -> General settings page.

Not sure if this is needed or necessary to fix.

If @vyskoczilova confirms that this is working for CLI way too, we can close the ticket. Correct?

Zodiac1978 avatar Jun 17 '24 09:06 Zodiac1978

It works like a charm! Thanks guys! BTW, I just found this https://playground.wordpress.net/builder/builder.html and it's just great

vyskoczilova avatar Jun 18 '24 13:06 vyskoczilova

But there is still one CORS error in my browser console for this link: https://api.wordpress.org/themes/update-check/1.1/ on the Options -> General settings page.

@Zodiac1978 I'm not seeing any CORS issues on that page, and the cited endpoint should be working, can you verify and/or copy the error?

dd32 avatar Jun 19 '24 03:06 dd32

Marking this as fixed, as the original issue is resolved. If you can reproduce the CORS issues, let me know and I'll get that fixed up.

dd32 avatar Jun 19 '24 03:06 dd32

Everything fine @dd32 - I tried again and couldn't reproduce it. It was there, but maybe caching, or a temporary hiccup 👍

Zodiac1978 avatar Jun 19 '24 07:06 Zodiac1978