| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
use YayMail\Utils\TemplateHelpers; |
| 7 |
|
| 8 |
$template = ! empty( $args['template'] ) ? $args['template'] : null; |
| 9 |
$text_link_color = ! empty( $template ) ? $template->get_text_link_color() : YAYMAIL_COLOR_WC_DEFAULT; |
| 10 |
$data = isset( $args['element']['data'] ) ? $args['element']['data'] : []; |
| 11 |
$is_placeholder = isset( $args['is_placeholder'] ) ? $args['is_placeholder'] : false; |
| 12 |
|
| 13 |
$settings = yaymail_settings(); |
| 14 |
$direction = yaymail_get_email_direction(); |
| 15 |
$show_product_image = isset( $settings['show_product_image'] ) ? boolval( $settings['show_product_image'] ) : false; |
| 16 |
|
| 17 |
|
| 18 |
$product_title = isset( $data['table_titles']['product_title'] ) ? $data['table_titles']['product_title'] : TemplateHelpers::get_content_as_placeholder( 'product_title', esc_html__( 'Products', 'woocommerce' ), $is_placeholder ); |
| 19 |
$expires_title = isset( $data['table_titles']['expires_title'] ) ? $data['table_titles']['expires_title'] : TemplateHelpers::get_content_as_placeholder( 'expires_title', esc_html__( 'Expires', 'woocommerce' ), $is_placeholder ); |
| 20 |
$download_title = isset( $data['table_titles']['download_title'] ) ? $data['table_titles']['download_title'] : TemplateHelpers::get_content_as_placeholder( 'download_title', esc_html__( 'Download', 'woocommerce' ), $is_placeholder ); |
| 21 |
|
| 22 |
$table_heading_font_size = isset( $data['table_heading_font_size'] ) ? $data['table_heading_font_size'] : 14; |
| 23 |
$table_content_font_size = isset( $data['table_content_font_size'] ) ? $data['table_content_font_size'] : 14; |
| 24 |
|
| 25 |
$table_td_style = TemplateHelpers::get_style( |
| 26 |
[ |
| 27 |
'padding' => '12px', |
| 28 |
'text-align' => yaymail_get_text_align(), |
| 29 |
'font-family' => TemplateHelpers::get_font_family_value( isset( $data['font_family'] ) ? $data['font_family'] : 'inherit' ), |
| 30 |
'color' => isset( $data['text_color'] ) ? $data['text_color'] : 'inherit', |
| 31 |
'border' => isset( $data['border_color'] ) ? '1px solid ' . $data['border_color'] : 'inherit', |
| 32 |
] |
| 33 |
); |
| 34 |
|
| 35 |
$table_link_style = TemplateHelpers::get_style( |
| 36 |
[ |
| 37 |
'color' => $text_link_color, |
| 38 |
'font-family' => TemplateHelpers::get_font_family_value( isset( $data['font_family'] ) ? $data['font_family'] : 'inherit' ), |
| 39 |
] |
| 40 |
); |
| 41 |
?> |
| 42 |
|
| 43 |
<tbody style="<?php echo esc_attr( $table_td_style ); ?>"> |
| 44 |
<tr style="<?php echo esc_attr( $table_td_style ); ?>"> |
| 45 |
<th class="td yaymail-order-details-download-title--product" colspan="1" scope="col" style="<?php echo esc_attr( $table_td_style ); ?> font-size: <?php echo esc_attr( $table_heading_font_size ); ?>px;"><?php yaymail_kses_post_e( $product_title ); ?></th> |
| 46 |
<th class="td yaymail-order-details-download-title--expires" colspan="1" scope="col" style="<?php echo esc_attr( $table_td_style ); ?> font-size: <?php echo esc_attr( $table_heading_font_size ); ?>px;"><?php yaymail_kses_post_e( $expires_title ); ?></th> |
| 47 |
<th class="td yaymail-order-details-download-title--download" colspan="1" scope="col" style="<?php echo esc_attr( $table_td_style ); ?> font-size: <?php echo esc_attr( $table_heading_font_size ); ?>px;"><?php yaymail_kses_post_e( $download_title ); ?></th> |
| 48 |
</tr> |
| 49 |
<tr style="<?php echo esc_attr( $table_td_style ); ?>"> |
| 50 |
<td class="td yaymail-order-details-download-content--product" colspan="1" scope="col" style="<?php echo esc_attr( $table_td_style ); ?> font-size: <?php echo esc_attr( $table_content_font_size ); ?>px;"> |
| 51 |
<?php |
| 52 |
if ( $show_product_image ) : |
| 53 |
$image_url = wc_placeholder_img_src(); |
| 54 |
$image_width = isset( $settings['product_image_width'] ) ? $settings['product_image_width'] : '30'; |
| 55 |
$image_height = isset( $settings['product_image_height'] ) ? $settings['product_image_height'] : '30'; |
| 56 |
$image_position = isset( $settings['product_image_position'] ) ? $settings['product_image_position'] : 'top'; |
| 57 |
|
| 58 |
$image_style = |
| 59 |
[ |
| 60 |
'margin-bottom' => '5px', |
| 61 |
'margin-right' => '5px', |
| 62 |
]; |
| 63 |
if ( $image_position === 'left' && ! $is_placeholder ) { |
| 64 |
if ( 'ltr' === $direction ) { |
| 65 |
$image_style['float'] = 'left'; |
| 66 |
} else { |
| 67 |
$image_style['float'] = 'right'; |
| 68 |
$image_style['margin-right'] = '0'; |
| 69 |
$image_style['margin-left'] = '5px'; |
| 70 |
} |
| 71 |
} |
| 72 |
$image_style = TemplateHelpers::get_style( $image_style ); |
| 73 |
$image = $is_placeholder ? "<img width='{{product_image_width}}px' height='{{product_image_height}}px' src='{$image_url}' alt='product image' style='{$image_style}'/>" : "<img width='{$image_width}px' height='{$image_height}px' src='{$image_url}' alt='product image' style='{$image_style}'/>"; |
| 74 |
|
| 75 |
?> |
| 76 |
<div class="yaymail-product-download-image"> |
| 77 |
<a href="" style="<?php echo esc_attr( $table_link_style ); ?>"> |
| 78 |
<?php |
| 79 |
if ( $is_placeholder || ( $image_position === 'top' || $image_position === 'left' ) ) { |
| 80 |
echo wp_kses_post( "<span class='yaymail-product_image_position__top'>" ); |
| 81 |
require YAYMAIL_PLUGIN_PATH . 'templates/shortcodes/order-details/order-items/image-content.php'; |
| 82 |
echo ( '</span>' ); |
| 83 |
} |
| 84 |
?> |
| 85 |
<span><?php esc_html_e( 'Downloadable Product', 'yaymail' ); ?></span> |
| 86 |
<?php |
| 87 |
if ( $is_placeholder || ( $image_position === 'bottom' ) ) { |
| 88 |
echo wp_kses_post( "<span class='yaymail-product_image_position__bottom'>" ); |
| 89 |
require YAYMAIL_PLUGIN_PATH . 'templates/shortcodes/order-details/order-items/image-content.php'; |
| 90 |
echo ( '</span>' ); |
| 91 |
} |
| 92 |
?> |
| 93 |
</a> |
| 94 |
</div> |
| 95 |
<?php else : ?> |
| 96 |
<a href="" style="<?php echo esc_attr( $table_link_style ); ?>"> |
| 97 |
<?php esc_html_e( 'Downloadable Product', 'yaymail' ); ?> |
| 98 |
</a> |
| 99 |
<?php endif; ?> |
| 100 |
</td> |
| 101 |
<td class="td yaymail-order-details-download-content--expires" colspan="1" scope="col" style="<?php echo esc_attr( $table_td_style ); ?> font-size: <?php echo esc_attr( $table_content_font_size ); ?>px;"> |
| 102 |
<time datetime="2021-02-13" title="1613174400"> <?php echo wp_kses_post( wc_format_datetime( new WC_DateTime() ) ); ?></time> |
| 103 |
</td> |
| 104 |
<td class="td yaymail-order-details-download-content--download" colspan="1" scope="col" style="<?php echo esc_attr( $table_td_style ); ?> font-size: <?php echo esc_attr( $table_content_font_size ); ?>px;"> |
| 105 |
<a href="" style="<?php echo esc_attr( $table_link_style ); ?>" ><?php esc_html_e( 'Download.doc', 'yaymail' ); ?></a> |
| 106 |
</td> |
| 107 |
</tr> |
| 108 |
</tbody> |
| 109 |
|
| 110 |
|