[Resolved] ways to register WPML apart from plugin-install-dot-php ?
This thread is resolved. Here is a description of the problem and solution.
Problem: The client is trying to register WPML on a WordPress site hosted on Pantheon, which blocks access to the standard registration URL (wp-admin/plugin-install.php). The client cannot use the PHP constant method for adding the registration key due to security policies that prevent adding sensitive information to the git code repository.
Solution: We recommend storing the WPML license keys in text files within a private, non-version-controlled directory, such as
wp-content/uploads/private/
on Pantheon. The client should name the text files according to the Pantheon environment name or the local Lando subdomain. For example, the live environment would use 'live.txt'.
The client can then use the following code snippet in the
wp-config.php
file to automatically load the correct license key file based on the environment:
Hello, is there a way to register WPML from within the WordPress UI, without visiting wp-admin/plugin-install.php? Our hosting provider -- Pantheon -- blocks access to this URL in production.
I believe that there used to be some other way to register WPML in the WordPress UI but I can't seem to find it in WPML 4.6.x. Our copy of WPML was registered in production until we upgraded to WordPress 6.4.1 and WPML 4.6.8 this week, and now WPML is no longer registered.
Or is there a database field where we can add the registration number? I can directly edit our site database as needed.
I know that we can in theory set a PHP constant with the registration key but that's problematic in our case, also related to our hosting setup.
Unfortunately, here's the reason that I wrote that "I know that we can in theory set a PHP constant with the registration key but that's problematic in our case, also related to our hosting setup."
We can't add our license keys to wp-config.php because that's part of our git code repository, and we can't add license keys to our code due to security policies.
Is there a way to handle this within the WordPress UI? There used to be some other URL where we could register WPML because that's what I used in the past to register WPML in production on Pantheon and it was working for almost two years until this week, and now I can't seem to find the URL or documentation about this other UI option.
I tried to check this with my colleagues, too - there might be a "register" url in the main Plugins page, under the plugin name but that might lead to the same URL. I was not able to find any other URL as you mentioned, I checked more than 20 existing tickets about pantheon. Unfortunately, they keep adding more and more obstructions to their system it seems.
There's also this recommendation from their URL (I will also attach a screenshot) but if you already have WPML configured, you won't see that part.
My recommendation is to get in touch with their support and ask for their help.
This is unfortunately not something caused by WPML. We constantly get people that have issues with this provider.
I guess people will have to keep creating support tickets, continue to be unhappy, and at some point, they might do some things to really fix these and not just come with workarounds.
I would have loved to at least be able to offer a workaround but I can't at this point, especially taking into consideration the git repository security policies.
The wp-config.php workaround was the most popular one and all of the customers confirmed that this does the trick.
Thank you, Mihai. Based on what you shared, I created a workaround for wp-config.php which enables us to use this constant but also keep the license keys out of our code repository for the sake of security -- never put license keys in your code repo! -- and flexibility in case we need to quick add or edit keys.
If it helps to share it here for others who use Pantheon, this is the solution that I created:
We now store WPML license keys inside of text files, where the name of the text file matches the Pantheon environment name or the local Lando subdomain.
So the license key for the live environment is `live.txt`, a multidev env named 'wpml' would use a key named `wpml.txt`, and a local env with a URL like `mylocalenv.lnod.site` would use a key named `mylocalenv.txt`.
We place these keys in a path that is private and *not* under version control, and Pantheon provides an existing path helps with this:
wp-content/uploads/private/
On Pantheon, that's a symlink for this path:
/files/private/
We use SFTP to create text files within a 'wpml' subfolder that we created within this path, and we insert the license keys into our text files.
From there we have the following code within wp-config.php to load the correct license key files automatically.
I hope that this helps anyone else who is facing the same problem, who needs a secure, flexible solution.
/*
* Define WPML license keys, based on environment name
*
* For example, a multidev domain named 'wpml' would have a license key file named 'wpml.txt'; the live env would use 'live.txt'; and Lando envs like 'localwww.lndo.site' would use a file named 'localwww'.
* License keys are stored within this folder, managed by SFTP: wp-content/uploads/private/wpml/ , aka /files/private/wpml on Pantheon
* This path is not under version control, intentionally, to keep license keys out of our code repo for improved security and flexibility.
*/
if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ) {
// Prepare the license key path, where we'll find the WPML license key files
$wpml_license_key_path = ABSPATH . 'wp-content/uploads/private/wpml/';
// Determine what the license file filename is
if ( isset( $_SERVER['LANDO_APP_COMMON_NAME'] ) ) {
// For Lando, use the local subdomain, such as maybe 'localwww'
$wpml_expected_license_file = $wpml_license_key_path . $_SERVER['LANDO_APP_COMMON_NAME'] . '.txt';
} else {
// For other environments, use the Pantheon env name, e.g. 'maintenance', 'dev,', 'test', 'live'
$wpml_expected_license_file = $wpml_license_key_path . $_ENV['PANTHEON_ENVIRONMENT'] . '.txt';
}
if ( file_exists( $wpml_expected_license_file ) ) {
// Get the WPML license key from the text file, and tell WPML to use it as the environment's license key.
$wpml_license_key = file_get_contents($wpml_expected_license_file);
define( 'OTGS_INSTALLER_SITE_KEY_WPML', $wpml_license_key );
}
}