Switch template registration to use register_block_template

[MAILPOET-6356]
This commit is contained in:
Rostislav Wolny
2024-12-13 15:59:42 +01:00
committed by Rostislav Wolný
parent 62b77b724c
commit 2fc0ad3c9e
5 changed files with 40 additions and 16 deletions

View File

@@ -73,6 +73,7 @@ class IntegrationTester extends \Codeception\Actor {
*/
public function cleanup(): void {
$this->delete_posts();
$this->unregister_block_templates();
}
/**
@@ -94,4 +95,17 @@ class IntegrationTester extends \Codeception\Actor {
}
$this->cleanup_user_theme_post();
}
/**
* Unregister block templates we may add during the tests.
*/
private function unregister_block_templates(): void {
$registry = WP_Block_Templates_Registry::get_instance();
$templates = $registry->get_all_registered();
foreach ( $templates as $name => $template ) {
if ( 'mailpoet' === $template->plugin && $registry->is_registered( $name ) ) {
$registry->unregister( $name );
}
}
}
}