| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
use YayMail\Utils\TemplateHelpers; |
| 5 |
|
| 6 |
/** |
| 7 |
* $args includes |
| 8 |
* $element |
| 9 |
* $render_data |
| 10 |
* $is_nested |
| 11 |
*/ |
| 12 |
if ( empty( $args['element'] ) ) { |
| 13 |
return; |
| 14 |
} |
| 15 |
|
| 16 |
$element = $args['element']; |
| 17 |
$data = $element['data']; |
| 18 |
|
| 19 |
$wrapper_style = TemplateHelpers::get_style( |
| 20 |
[ |
| 21 |
'background-color' => $data['background_color'], |
| 22 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data['padding'] ) ? $data['padding'] : [] ), |
| 23 |
] |
| 24 |
); |
| 25 |
|
| 26 |
// Handle table alignment |
| 27 |
$table_margin = '0 auto'; |
| 28 |
if ( isset( $data['align'] ) ) { |
| 29 |
switch ( $data['align'] ) { |
| 30 |
case 'center': |
| 31 |
$table_margin = '0 auto'; |
| 32 |
break; |
| 33 |
case 'right': |
| 34 |
$table_margin = '0 0 0 auto'; |
| 35 |
break; |
| 36 |
case 'left': |
| 37 |
default: |
| 38 |
$table_margin = '0'; |
| 39 |
break; |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
$width_value = TemplateHelpers::get_dimension_value( $data['width'], '%' ); |
| 44 |
|
| 45 |
$table_style = TemplateHelpers::get_style( |
| 46 |
[ |
| 47 |
'border-collapse' => 'collapse', |
| 48 |
'width' => $width_value, |
| 49 |
'min-width' => $width_value, |
| 50 |
'margin' => $table_margin, |
| 51 |
] |
| 52 |
); |
| 53 |
|
| 54 |
$cell_style = TemplateHelpers::get_style( |
| 55 |
[ |
| 56 |
'width' => TemplateHelpers::get_dimension_value( $data['width'], '%' ), |
| 57 |
'border-top-width' => TemplateHelpers::get_dimension_value( $data['height'] ), |
| 58 |
'border-top-color' => $data['divider_color'], |
| 59 |
'border-top-style' => $data['divider_type'], |
| 60 |
'padding' => '0', |
| 61 |
'margin' => '0', |
| 62 |
'line-height' => '0', |
| 63 |
] |
| 64 |
); |
| 65 |
|
| 66 |
ob_start(); |
| 67 |
?> |
| 68 |
<table class="yaymail-customizer-element-divider" cellpadding="0" cellspacing="0" role="presentation" style="<?php echo esc_attr( $table_style ); ?>"> |
| 69 |
<tbody> |
| 70 |
<tr> |
| 71 |
<td style="<?php echo esc_attr( $cell_style ); ?>"> |
| 72 |
|
| 73 |
</td> |
| 74 |
</tr> |
| 75 |
</tbody> |
| 76 |
</table> |
| 77 |
<?php |
| 78 |
$element_content = ob_get_clean(); |
| 79 |
|
| 80 |
TemplateHelpers::wrap_element_content( $element_content, $element, $wrapper_style ); |
| 81 |
|