I'm writing a plugin and I've just added a check for a minimum PHP version. I tried to i18n the error message but it doesn't work. I translated every string in the plugin, everything works correctly except that one, so the error is always displayed in english. Here's my code:
/**
* Plugin Name: plugintest
* Description: test
* Version: 1.0
* Author: me
* Text Domain: plugintest
* Domain Path: /languages/
*/
add_action('plugins_loaded', 'plugintest_load_plugin_textdomain');
// Languages
function plugintest_load_plugin_textdomain() {
load_plugin_textdomain( 'plugintest', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
// Check for required PHP version
if (version_compare(PHP_VERSION, '5.4', '<'))
{
$phpoldmsg = __('This plugin requires PHP 5.4 or higher. Please upgrade the version of PHP installed on your server', 'plugintest');
$phpoldmsg .= " (".PHP_VERSION.")";
exit($phpoldmsg);
}
else{
include 'plugintest.php';//INCLUDE REST OF PLUGIN
}
I guess it's because the plugin textdomain is not loaded yet when the message is displayed but I can't figure how to solve this. I read somewhere that by adding "Text Domain" and "Domain Path" in the plugin header WP is supposed to translate the strings even before the activation, but it doesn't seem to help me. Or should I use an earlier hook than "plugins_loaded"? Thank you in advance