| 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 |
$shipping_content_format = [ |
| 14 |
'bold' => isset( $data['shipping_content_text_format']['bold'] ) ? filter_var( $data['shipping_content_text_format']['bold'], FILTER_VALIDATE_BOOLEAN ) : false, |
| 15 |
'italic' => isset( $data['shipping_content_text_format']['italic'] ) ? filter_var( $data['shipping_content_text_format']['italic'], FILTER_VALIDATE_BOOLEAN ) : true, |
| 16 |
'underline' => isset( $data['shipping_content_text_format']['underline'] ) ? filter_var( $data['shipping_content_text_format']['underline'], FILTER_VALIDATE_BOOLEAN ) : false, |
| 17 |
]; |
| 18 |
|
| 19 |
$shipping_content_alignment = isset( $data['shipping_content_alignment'] ) ? $data['shipping_content_alignment'] : 'left'; |
| 20 |
|
| 21 |
$shipping_address_html = wp_kses_post( do_shortcode( isset( $data['rich_text'] ) ? $data['rich_text'] : '[yaymail_shipping_address]' ) ); |
| 22 |
|
| 23 |
if ( empty( $shipping_address_html ) ) : |
| 24 |
return ''; |
| 25 |
endif; |
| 26 |
|
| 27 |
$wrapper_style = TemplateHelpers::get_style( |
| 28 |
[ |
| 29 |
'word-break' => 'break-word', |
| 30 |
'background-color' => $data['background_color'], |
| 31 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data['padding'] ) ? $data['padding'] : [] ), |
| 32 |
] |
| 33 |
); |
| 34 |
|
| 35 |
$shipping_border_style = TemplateHelpers::get_style( |
| 36 |
[ |
| 37 |
'border' => 'solid 1px ' . $data['border_color'], |
| 38 |
] |
| 39 |
); |
| 40 |
|
| 41 |
$shipping_wrapper_style = TemplateHelpers::get_style( |
| 42 |
[ |
| 43 |
'color' => isset( $data['text_color'] ) ? $data['text_color'] : 'inherit', |
| 44 |
'padding' => '12px', |
| 45 |
'text-align' => yaymail_get_text_align(), |
| 46 |
'font-size' => TemplateHelpers::get_dimension_value( $data['shipping_content_font_size'] ?? 14 ), |
| 47 |
'font-family' => TemplateHelpers::get_font_family_value( isset( $data['font_family'] ) ? $data['font_family'] : 'inherit' ), |
| 48 |
'border' => 'solid 1px ' . $data['border_color'], |
| 49 |
'text-align' => $shipping_content_alignment, |
| 50 |
] |
| 51 |
); |
| 52 |
|
| 53 |
$title_style = TemplateHelpers::get_style( |
| 54 |
[ |
| 55 |
'text-align' => yaymail_get_text_align(), |
| 56 |
'color' => isset( $data['title_color'] ) ? $data['title_color'] : 'inherit', |
| 57 |
'margin' => '0 0 7px 0', |
| 58 |
'font-size' => '20px', |
| 59 |
'font-weight' => '600', |
| 60 |
'font-family' => TemplateHelpers::get_font_family_value( isset( $data['font_family'] ) ? $data['font_family'] : 'inherit' ), |
| 61 |
] |
| 62 |
); |
| 63 |
|
| 64 |
$is_layout_type_modern = isset( $data['layout_type'] ) && 'modern' === $data['layout_type']; |
| 65 |
|
| 66 |
ob_start(); |
| 67 |
?> |
| 68 |
<style> |
| 69 |
/* Modern layout */ |
| 70 |
<?php if ( $is_layout_type_modern ) { ?> |
| 71 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-shipping-address-wrap { |
| 72 |
border: 0 !important; |
| 73 |
padding-left: 0 !important; |
| 74 |
padding-right: 0 !important; |
| 75 |
} |
| 76 |
<?php |
| 77 |
}//end if |
| 78 |
?> |
| 79 |
.yaymail-element-<?php echo esc_attr( $element['id'] ); ?> .yaymail-shipping-address-wrap address { |
| 80 |
font-weight: <?php echo esc_attr( $shipping_content_format['bold'] ?? false ? 'bold' : 'normal' ); ?> !important; |
| 81 |
font-style: <?php echo esc_attr( $shipping_content_format['italic'] ?? false ? 'italic' : 'normal' ); ?> !important; |
| 82 |
text-decoration: <?php echo esc_attr( $shipping_content_format['underline'] ?? false ? 'underline' : 'none' ); ?> !important; |
| 83 |
} |
| 84 |
</style> |
| 85 |
<div class="yaymail-shipping-title" style="<?php echo esc_attr( $title_style ); ?>" > <?php echo wp_kses_post( do_shortcode( $data['title'] ) ); ?> </div> |
| 86 |
<div class="yaymail-shipping-address-wrap" style="<?php echo esc_attr( $shipping_wrapper_style ); ?>"> |
| 87 |
<?php echo wp_kses_post( do_shortcode( isset( $data['rich_text'] ) ? $data['rich_text'] : '[yaymail_shipping_address]' ) ); ?> |
| 88 |
</div> |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
<?php |
| 93 |
$element_content = ob_get_clean(); |
| 94 |
TemplateHelpers::wrap_element_content( $element_content, $element, $wrapper_style ); |
| 95 |
|
| 96 |
|