Add service for checking editor dependencies
[MAILPOET-6367]
This commit is contained in:
committed by
Oluwaseun Olorunsola
parent
5decd55bf7
commit
dd2c88dfbe
@@ -337,6 +337,7 @@ class ContainerConfigurator implements IContainerConfigurator {
|
||||
$container->autowire(\MailPoet\CustomFields\CustomFieldsRepository::class)->setPublic(true);
|
||||
// Email Editor
|
||||
$container->autowire(\MailPoet\EmailEditor\Engine\Email_Editor::class)->setPublic(true);
|
||||
$container->autowire(\MailPoet\EmailEditor\Engine\Dependency_Check::class)->setPublic(true);
|
||||
$container->autowire(\MailPoet\EmailEditor\Engine\Email_Api_Controller::class)->setPublic(true);
|
||||
$container->autowire(\MailPoet\EmailEditor\Engine\Settings_Controller::class)->setPublic(true);
|
||||
$container->autowire(\MailPoet\EmailEditor\Engine\Theme_Controller::class)->setPublic(true);
|
||||
|
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the MailPoet Email Editor package.
|
||||
*
|
||||
* @package MailPoet\EmailEditor
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
namespace MailPoet\EmailEditor\Engine;
|
||||
|
||||
/**
|
||||
* This class is responsible checking the dependencies of the email editor.
|
||||
*/
|
||||
class Dependency_Check {
|
||||
/**
|
||||
* Minimum WordPress version required for the email editor.
|
||||
*/
|
||||
public const MIN_WP_VERSION = '6.7';
|
||||
|
||||
/**
|
||||
* Minimum Gutenberg version required for the email editor.
|
||||
*
|
||||
* @see https://developer.wordpress.org/block-editor/contributors/versions-in-wordpress/
|
||||
*/
|
||||
public const MIN_GUTENBERG_VERSION = '19.3'; // Version released in WP 6.7.
|
||||
|
||||
/**
|
||||
* Checks if all dependencies are met.
|
||||
*/
|
||||
public function are_dependencies_met(): bool {
|
||||
return $this->is_gutenberg_version_compatible() || $this->is_wp_version_compatible();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the WordPress version is supported.
|
||||
*/
|
||||
private function is_wp_version_compatible(): bool {
|
||||
return version_compare( get_bloginfo( 'version' ), self::MIN_WP_VERSION, '>=' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the WordPress version is supported.
|
||||
*/
|
||||
private function is_gutenberg_version_compatible(): bool {
|
||||
return version_compare( get_bloginfo( 'version' ), self::MIN_GUTENBERG_VERSION, '>=' );
|
||||
}
|
||||
}
|
@@ -9,6 +9,7 @@ declare(strict_types = 1);
|
||||
|
||||
use Codeception\Stub;
|
||||
use MailPoet\EmailEditor\Container;
|
||||
use MailPoet\EmailEditor\Engine\Dependency_Check;
|
||||
use MailPoet\EmailEditor\Engine\Email_Api_Controller;
|
||||
use MailPoet\EmailEditor\Engine\Email_Editor;
|
||||
use MailPoet\EmailEditor\Engine\Patterns\Patterns;
|
||||
@@ -293,6 +294,12 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { // phpcs:ignore
|
||||
);
|
||||
}
|
||||
);
|
||||
$container->set(
|
||||
Dependency_Check::class,
|
||||
function () {
|
||||
return new Dependency_Check();
|
||||
}
|
||||
);
|
||||
$container->set(
|
||||
Email_Editor::class,
|
||||
function ( $container ) {
|
||||
|
Reference in New Issue
Block a user