| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
use YayMail\Utils\TemplateHelpers; |
| 5 |
|
| 6 |
if ( empty( $args['element'] ) ) { |
| 7 |
return; |
| 8 |
} |
| 9 |
|
| 10 |
$element = $args['element']; |
| 11 |
$data = $element['data']; |
| 12 |
|
| 13 |
$wrapper_style = TemplateHelpers::get_style( |
| 14 |
[ |
| 15 |
'word-break' => 'break-word', |
| 16 |
'background-color' => $data['background_color'], |
| 17 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data['padding'] ) ? $data['padding'] : [] ), |
| 18 |
] |
| 19 |
); |
| 20 |
|
| 21 |
$title_style = TemplateHelpers::get_style( |
| 22 |
[ |
| 23 |
'text-align' => yaymail_get_text_align(), |
| 24 |
'color' => isset( $data['title_color'] ) ? $data['title_color'] : 'inherit', |
| 25 |
'margin-top' => '0', |
| 26 |
'margin-bottom' => '7px', |
| 27 |
'font-family' => TemplateHelpers::get_font_family_value( isset( $data['font_family'] ) ? $data['font_family'] : 'inherit' ), |
| 28 |
] |
| 29 |
); |
| 30 |
|
| 31 |
$is_layout_type_modern = isset( $data['layout_type'] ) && 'modern' === $data['layout_type']; |
| 32 |
|
| 33 |
$table_style = TemplateHelpers::get_style( |
| 34 |
[ |
| 35 |
'font-size' => '14px', |
| 36 |
'text-align' => yaymail_get_text_align(), |
| 37 |
'font-family' => TemplateHelpers::get_font_family_value( ! empty( $data['font_family'] ) ? $data['font_family'] : 'inherit' ), |
| 38 |
'color' => ! empty( $data['text_color'] ) ? $data['text_color'] : 'inherit', |
| 39 |
'border-collapse' => $is_layout_type_modern ? 'collapse' : 'separate', |
| 40 |
'border' => $is_layout_type_modern ? '0' : ( ! empty( $data['border_color'] ) ? '1px solid ' . $data['border_color'] : 'inherit' ), |
| 41 |
'mso-table-lspace' => $is_layout_type_modern ? '0pt' : null, |
| 42 |
'mso-table-rspace' => $is_layout_type_modern ? '0pt' : null, |
| 43 |
] |
| 44 |
); |
| 45 |
|
| 46 |
$shortcoded_title = isset( $data['title'] ) ? do_shortcode( $data['title'] ) : ''; |
| 47 |
$shortcoded_content = isset( $data['rich_text'] ) ? do_shortcode( $data['rich_text'] ) : ''; |
| 48 |
|
| 49 |
if ( empty( $shortcoded_content ) ) { |
| 50 |
return; |
| 51 |
} |
| 52 |
|
| 53 |
ob_start(); |
| 54 |
?> |
| 55 |
<style> |
| 56 |
/* Modern layout */ |
| 57 |
<?php if ( $is_layout_type_modern ) { ?> |
| 58 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-download-content { |
| 59 |
border: 0 !important; |
| 60 |
} |
| 61 |
|
| 62 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-download-content tbody, |
| 63 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-download-content tr, |
| 64 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-download-content th, |
| 65 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-download-content td { |
| 66 |
border: 0 !important; |
| 67 |
padding-left: 0 !important; |
| 68 |
padding-right: 0 !important; |
| 69 |
} |
| 70 |
|
| 71 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-download-title--download, |
| 72 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-order-details-download-content--download { |
| 73 |
text-align: right !important; |
| 74 |
} |
| 75 |
<?php |
| 76 |
}//end if |
| 77 |
?> |
| 78 |
</style> |
| 79 |
|
| 80 |
<div class="yaymail-order-details-download-title" style="<?php echo esc_attr( $title_style ); ?>" > <?php yaymail_kses_post_e( $shortcoded_title ); ?></div> |
| 81 |
<table class="yaymail-order-details-download-content" style="<?php echo esc_attr( $table_style ); ?>" border="0" cellpadding="6" cellspacing="0" width="100%" > |
| 82 |
<?php yaymail_kses_post_e( $shortcoded_content ); ?> |
| 83 |
</table> |
| 84 |
<?php |
| 85 |
$element_content = ob_get_clean(); |
| 86 |
TemplateHelpers::wrap_element_content( $element_content, $element, $wrapper_style ); |
| 87 |
|