PluginProbe
YayMail – WooCommerce Email Customizer / 4.3.4
YayMail – WooCommerce Email Customizer v4.3.4
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 4.3.4, at src/Utils/TemplateRenderer.php

50 lines 1.3 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
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * TemplateRenderer Classes
15 * Define all utility functions to be used for rendering templates
16 */
17 class TemplateRenderer {
18
19 public $template = null;
20
21 public function __construct( $template ) {
22 if ( $template instanceof YayMailTemplate ) {
23 $this->template = $template;
24 }
25 }
26
27 public function generate_content( $render_data ) {
28 if ( empty( $this->template ) ) {
29 return '';
30 }
31
32 // Handle the cases when order is numeric (order_id)
33 if ( isset( $render_data['order'] ) && is_numeric( $render_data['order'] ) ) {
34 $order = wc_get_order( $render_data['order'] );
35 if ( $order ) {
36 $render_data['order'] = $order;
37 }
38 }
39
40 // TODO: Need to generate render_data based on email type
41 $args = [
42 'template' => $this->template,
43 'render_data' => $render_data,
44 'settings' => yaymail_settings(),
45 ];
46
47 return yaymail_get_content( 'templates/emails/email-content.php', $args );
48 }
49 }
50