Move simple-light template from the engine/package to the free plugin

The additional templates are registered by integrators.
This way, we will be able to use assets like images from MailPoet's CDN
and also various services from the plugins (e.g. CdnAssetsController)
[MAILPOET-6356]
This commit is contained in:
Rostislav Wolny
2024-12-16 14:55:20 +01:00
committed by Rostislav Wolný
parent 6eca06780f
commit 2c3932bdd3
5 changed files with 59 additions and 22 deletions

View File

@@ -33,12 +33,6 @@ class Templates {
* @var string $template_directory
*/
private string $template_directory = __DIR__ . DIRECTORY_SEPARATOR;
/**
* The templates.
*
* @var array $templates
*/
private array $templates = array();
/**
* Initializes the class.
@@ -69,27 +63,24 @@ class Templates {
if ( ! function_exists( 'register_block_template' ) ) {
return;
}
$this->templates['email-general'] = array(
// Register basic blank template.
$general_email = array(
'title' => __( 'General Email', 'mailpoet' ),
'description' => __( 'A general template for emails.', 'mailpoet' ),
'slug' => 'email-general',
);
$this->templates['simple-light'] = array(
'title' => __( 'Simple Light', 'mailpoet' ),
'description' => __( 'A basic template with header and footer.', 'mailpoet' ),
$template_filename = $general_email['slug'] . '.html';
register_block_template(
$this->template_prefix . '//' . $general_email['slug'],
array(
'title' => $general_email['title'],
'description' => $general_email['description'],
'content' => (string) file_get_contents( $this->template_directory . $template_filename ),
'post_types' => array( $this->post_type ),
)
);
foreach ( $this->templates as $template_slug => $template ) {
$template_filename = $template_slug . '.html';
register_block_template(
$this->template_prefix . '//' . $template_slug,
array(
'title' => $template['title'],
'description' => $template['description'],
'content' => (string) file_get_contents( $this->template_directory . $template_filename ),
'post_types' => array( $this->post_type ),
)
);
}
do_action( 'mailpoet_email_editor_register_templates' );
}

View File

@@ -1,48 +0,0 @@
<!-- wp:group {"backgroundColor":"white","style":{"spacing":{"padding":{"top":"var:preset|spacing|10","bottom":"var:preset|spacing|10","left":"var:preset|spacing|20","right":"var:preset|spacing|20"}}},"layout":{"type":"constrained"}} -->
<div
class="wp-block-group has-white-background-color has-background"
style="
padding-top: var(--wp--preset--spacing--10);
padding-right: var(--wp--preset--spacing--20);
padding-bottom: var(--wp--preset--spacing--10);
padding-left: var(--wp--preset--spacing--20);
"
>
<!-- wp:image {"width":"130px","sizeSlug":"large"} -->
<figure class="wp-block-image size-large is-resized">
<img
src="https://ps.w.org/mailpoet/assets/email-editor/your-logo-placeholder.png"
alt="Your Logo"
style="width: 130px"
/>
</figure>
<!-- /wp:image -->
</div>
<!-- /wp:group -->
<!-- wp:post-content {"lock":{"move":false,"remove":false},"layout":{"type":"default"}} /-->
<!-- wp:group {"backgroundColor":"white","style":{"spacing":{"padding":{"top":"var:preset|spacing|10","bottom":"var:preset|spacing|10","left":"var:preset|spacing|20","right":"var:preset|spacing|20"}}},"layout":{"type":"constrained"}} -->
<div
class="wp-block-group has-white-background-color has-background"
style="
padding-top: var(--wp--preset--spacing--10);
padding-right: var(--wp--preset--spacing--20);
padding-bottom: var(--wp--preset--spacing--10);
padding-left: var(--wp--preset--spacing--20);
"
>
<!-- wp:paragraph {"fontSize":"small"} -->
<p class="has-small-font-size">
You received this email because you are subscribed to the [site:title]
</p>
<!-- /wp:paragraph -->
<!-- wp:paragraph {"fontSize":"small"} -->
<p class="has-small-font-size">
<a href="[link:subscription_unsubscribe_url]">Unsubscribe</a> |
<a href="[link:subscription_manage_url]">Manage subscription</a>
</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->