| 1 |
<?php |
| 2 |
use YayMail\Elements\ElementsLoader; |
| 3 |
use YayMail\Models\TemplateModel; |
| 4 |
use YayMail\Utils\TemplateHelpers; |
| 5 |
use YayMail\GlobalHeaderFooter; |
| 6 |
|
| 7 |
defined( 'ABSPATH' ) || exit; |
| 8 |
|
| 9 |
/** |
| 10 |
* $args includes |
| 11 |
* $template |
| 12 |
* $render_data |
| 13 |
* $settings |
| 14 |
*/ |
| 15 |
|
| 16 |
$template = isset( $args['template'] ) ? $args['template'] : null; |
| 17 |
// YayMailTemplate instance |
| 18 |
$render_data = isset( $args['render_data'] ) ? $args['render_data'] : []; |
| 19 |
// Render data |
| 20 |
$yaymail_settings = yaymail_settings(); |
| 21 |
$container_direction = yaymail_get_email_direction(); |
| 22 |
$container_width = isset( $yaymail_settings['container_width'] ) && is_numeric( $yaymail_settings['container_width'] ) ? $yaymail_settings['container_width'] : '605'; |
| 23 |
|
| 24 |
$style_container = TemplateHelpers::get_style( |
| 25 |
[ |
| 26 |
'background' => $template->get_background_color(), |
| 27 |
'direction' => $container_direction, |
| 28 |
'margin' => '0 auto', |
| 29 |
] |
| 30 |
); |
| 31 |
|
| 32 |
$style_container_wrap = TemplateHelpers::get_style( |
| 33 |
[ |
| 34 |
'background' => $template->get_background_color(), |
| 35 |
'direction' => $container_direction, |
| 36 |
'margin' => '0 auto', |
| 37 |
'width' => '100%', |
| 38 |
'border-spacing' => '0', |
| 39 |
] |
| 40 |
); |
| 41 |
|
| 42 |
/** |
| 43 |
* Get global header and footer elements |
| 44 |
* |
| 45 |
* @since 4.1.0 |
| 46 |
*/ |
| 47 |
$global_header_footer_elements = GlobalHeaderFooter::get_elements( $template ); |
| 48 |
|
| 49 |
if ( ! empty( $template ) ) : |
| 50 |
?> |
| 51 |
|
| 52 |
<?php do_action( 'yaymail_before_email_content', $template, $render_data ); ?> |
| 53 |
<table style="<?php echo esc_attr( $style_container_wrap ); ?>" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%"> |
| 54 |
<tr> |
| 55 |
<td style="padding: 0;"> |
| 56 |
<table class="yaymail-template-content-container" style="width: <?php echo esc_attr( $container_width ); ?>px; margin: auto;border-spacing: 0;"> |
| 57 |
<tr> |
| 58 |
<td style="padding: 0;"> |
| 59 |
<table style="<?php echo esc_attr( $style_container ); ?>" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" class="yaymail-customizer-email-template-container <?php echo esc_attr( 'yaymail-template-' . $template->get_name() ); ?>"> |
| 60 |
<?php |
| 61 |
if ( ! empty( $global_header_footer_elements['global_header_elements'] ) ) { |
| 62 |
ElementsLoader::render_elements( $global_header_footer_elements['global_header_elements'], $args ); |
| 63 |
} |
| 64 |
?> |
| 65 |
<?php ElementsLoader::render_elements( $template->get_elements(), $args ); ?> |
| 66 |
<?php |
| 67 |
if ( ! empty( $global_header_footer_elements['global_footer_elements'] ) ) { |
| 68 |
ElementsLoader::render_elements( $global_header_footer_elements['global_footer_elements'], $args ); |
| 69 |
} |
| 70 |
?> |
| 71 |
</table> |
| 72 |
</td> |
| 73 |
</tr> |
| 74 |
</table> |
| 75 |
</td> |
| 76 |
</tr> |
| 77 |
</table> |
| 78 |
<?php do_action( 'yaymail_after_email_content', $template, $render_data ); ?> |
| 79 |
<?php endif; ?> |
| 80 |
|