Update the dependency check logic and the message

We actually need WP 6.7 and above, no matter what Gutenberg version
is installed. This commit updates the check logic and the warning
message to match this requirement.
[MAILPOET-6367]
This commit is contained in:
Rostislav Wolny
2025-01-09 15:22:13 +01:00
committed by Oluwaseun Olorunsola
parent 3f48d088f3
commit 0cb66ecc40
2 changed files with 11 additions and 6 deletions

View File

@@ -45,7 +45,7 @@ class DependencyNotice {
private function displayMessage(): void {
$dependencyErrorMessage = sprintf(
// translators: %1$s: WordPress version e.g. 6.7, %2$s: Gutenberg version e.g. 19.3
__('This email was created using the new editor, but it requires WordPress version %1$s or higher, or the Gutenberg plugin version %2$s or above. Please update your setup to continue editing or preview this email.', 'mailpoet'),
__('This email was created using the new editor, which requires WordPress version %1$s or higher. If you also have the Gutenberg plugin installed, ensure its version is %2$s or above. Please update your setup to continue editing or previewing this email.', 'mailpoet'),
Dependency_Check::MIN_WP_VERSION,
Dependency_Check::MIN_GUTENBERG_VERSION
);

View File

@@ -28,7 +28,13 @@ class Dependency_Check {
* Checks if all dependencies are met.
*/
public function are_dependencies_met(): bool {
return $this->is_gutenberg_version_compatible() || $this->is_wp_version_compatible();
if ( ! $this->is_wp_version_compatible() ) {
return false;
}
if ( is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
return $this->is_gutenberg_version_compatible();
}
return true;
}
/**
@@ -42,9 +48,8 @@ class Dependency_Check {
* Checks if the WordPress version is supported.
*/
private function is_gutenberg_version_compatible(): bool {
if ( defined( 'GUTENBERG_VERSION' ) ) {
return version_compare( GUTENBERG_VERSION, self::MIN_GUTENBERG_VERSION, '>=' );
}
return false;
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/gutenberg/gutenberg.php', false, false );
$version = $plugin_data['Version'] ?? '0.0.0';
return version_compare( $version, self::MIN_GUTENBERG_VERSION, '>=' );
}
}