required_php_version = $required_version;
$this->plugin_name = $plugin_name;
$this->plugin_file = $plugin_file;
$this->text_domain = $text_domain;
}
/**
* Check php version.
*
* @return bool
*/
public function is_ok() {
if ( version_compare( $this->required_php_version, phpversion(), '>' ) ) {
add_action( 'admin_notices', array( $this, 'php_requirement_message' ) );
return false;
}
return true;
}
/**
* Show notice with php requirement.
*/
public function php_requirement_message() {
load_plugin_textdomain( $this->text_domain, false, dirname( plugin_basename( $this->plugin_file ) ) . '/locale' );
$errata_page_link = 'https://wpml.org/errata/parse-error-syntax-error-unexpected-t_class-and-other-errors-when-using-php-versions-older-than-5-6/';
// phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralDomain
/* translators: 1: Current PHP version number, 2: Plugin version, 3: Minimum required PHP version number */
$message = sprintf( __( 'Your server is running PHP version %1$s but %2$s requires at least %3$s.', $this->text_domain ), phpversion(), $this->plugin_name, $this->required_php_version );
$message .= '
';
/* translators: Link to errata page */
$message .= sprintf( __( 'You can find version of the plugin suitable for your environment here.', $this->text_domain ), $errata_page_link );
// phpcs:enable WordPress.WP.I18n.NonSingularStringLiteralDomain
?>