Cloudways – How to use SSH / WP-CLI

#1 First, you need to enable SSH Access on Application Settings -> SSH Access -> “Enable”
#2 Define some FTP credentials as, they are also used for SSH
#3 Connect with “$ ssh -l marcel-test 178.62.22.152”

In this case, marcel-test is the FTP Username and the IP of my Cloudways Server
marcel-test / Marcel123#&456

#4 Now you are connected to the server and run several Linux commands such as “ls”, “ls- l”, “htop” etc.

# If you want to access now WP-CLI, it’s available by typing “wp”.

Examples:
wp user create marcel marcel.t+test@onthegosystems.com –role=administrator
wp plugin install wordpress-seo

Language Switcher loads CSS files from an old URL

If the CSS files of the language switcher are loading from an old URL after moving the website follow the steps below:

  • Go to “WordPress Dashboard > Support > Troubleshooting”.
  • Click the “Clear the cache in WPML” button.

The same thing is available via wp-cli command below:

wp wpml clear-cache

The command above is available in WPML 4.4.11 and above.

Translate PHP strings in WP-CLI custom command

When you switch languages using WPML API in the WP-CLI command callback, the strings are not translated. Please see wpmlsupp-9941 for more details.

You can workaround this by adding this code to a plugin or custom plugin but not a theme.

if (defined('WP_CLI') && WP_CLI) {
		add_filter('locale', function ($locale) {
			$command = $GLOBALS['argv'][1] ?? false;
			$lang = $GLOBALS['argv'][2] ?? false;

			if ('WPMLTest' === $command && !empty($lang)) {
				global $sitepress;
				$lang = method_exists($sitepress, 'get_locale_from_language_code') ? $sitepress->get_locale_from_language_code($lang) : $lang;
				return $lang;
			}

			return $locale;
		});
}

Make sure to replace WPMLTest with your command name.

Then run the command like this wp WPMLTest es where es language code in which you want to load the strings.
Your custom command callback will not need to switch the language using WPML API. The above function will change the locale using language parameter passed in the command line argument.

Please make sure you add your ticket to track the number of requests.