PluginProbe
YayMail – WooCommerce Email Customizer / trunk
YayMail – WooCommerce Email Customizer vtrunk
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / src / Utils / TemplateRenderer.php

TemplateRenderer.php in YayMail – WooCommerce Email Customizer trunk, at src/Utils/TemplateRenderer.php

52 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Utils;
4
5 use YayMail\Models\TemplateModel;
6 use YayMail\Shortcodes\ShortcodesExecutor;
7 use YayMail\Models\SettingModel;
8 use YayMail\YayMailTemplate;
9 use YayMail\Utils\TemplateHelpers;
10
11
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * TemplateRenderer Classes
16 * Define all utility functions to be used for rendering templates
17 */
18 class TemplateRenderer {
19
20 public $template = null;
21
22 public function __construct( $template ) {
23 if ( $template instanceof YayMailTemplate ) {
24 $this->template = $template;
25 }
26 }
27
28 public function generate_content( $render_data ) {
29 if ( empty( $this->template ) ) {
30 return '';
31 }
32
33 // Handle the cases when order is numeric (order_id)
34 if ( isset( $render_data['order'] ) && is_numeric( $render_data['order'] ) ) {
35 $order = wc_get_order( $render_data['order'] );
36 if ( $order ) {
37 $render_data['order'] = $order;
38 }
39 }
40
41 // TODO: Need to generate render_data based on email type
42 $args = [
43 'template' => $this->template,
44 'render_data' => $render_data,
45 'settings' => yaymail_settings(),
46 ];
47
48 $content = yaymail_get_content( 'templates/emails/email-content.php', $args );
49
50 return TemplateHelpers::replace_color_paths( $content );
51 }
52 }