| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
use YayMail\Utils\TemplateHelpers; |
| 4 |
|
| 5 |
if ( empty( $args['element'] ) ) { |
| 6 |
return; |
| 7 |
} |
| 8 |
|
| 9 |
$element = $args['element']; |
| 10 |
$data = $element['data']; |
| 11 |
$settings = $args['settings']; |
| 12 |
$container_width = isset( $settings['container_width'] ) ? $settings['container_width'] : 605; |
| 13 |
|
| 14 |
|
| 15 |
$data_column_default = is_array( $data['text_list']['column_1'] ) && ! empty( $data['text_list']['column_1'] ) ? $data['text_list']['column_1'] : [ |
| 16 |
'rich_text' => '<p><span style="font-size: 18px;"><strong>This is a title</strong></span></p><p> </p><p><span> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy.</span></p><p> </p><p><span>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</span></p>', |
| 17 |
'font_family' => YAYMAIL_DEFAULT_FAMILY, |
| 18 |
'padding' => [ |
| 19 |
'top' => '10', |
| 20 |
'right' => '10', |
| 21 |
'bottom' => '10', |
| 22 |
'left' => '50', |
| 23 |
], |
| 24 |
'show_button' => true, |
| 25 |
'button' => [ |
| 26 |
'type' => 'default', |
| 27 |
'text' => 'Click me', |
| 28 |
'align' => 'left', |
| 29 |
'height' => '21', |
| 30 |
'width' => '50', |
| 31 |
'weight' => 'normal', |
| 32 |
'font_family' => YAYMAIL_DEFAULT_FAMILY, |
| 33 |
'font_size' => '13', |
| 34 |
'url' => '#', |
| 35 |
'background_color' => YAYMAIL_COLOR_WC_DEFAULT, |
| 36 |
'text_color' => '#fff', |
| 37 |
'padding' => [ |
| 38 |
'top' => '0', |
| 39 |
'right' => '0', |
| 40 |
'bottom' => '0', |
| 41 |
'left' => '50', |
| 42 |
], |
| 43 |
'border_radius' => [ |
| 44 |
'top' => '5', |
| 45 |
'right' => '5', |
| 46 |
'bottom' => '5', |
| 47 |
'left' => '5', |
| 48 |
], |
| 49 |
], |
| 50 |
]; |
| 51 |
|
| 52 |
$data_column_1 = is_array( $data['text_list']['column_1'] ) && ! empty( $data['text_list']['column_1'] ) ? $data['text_list']['column_1'] : $data_column_default; |
| 53 |
if ( is_array( $data['text_list']['column_1'] ) && ! empty( $data['text_list']['column_1'] ) ) { |
| 54 |
$_data_column_1 = $data['text_list']['column_1']; |
| 55 |
foreach ( $_data_column_1 as $key => $value ) { |
| 56 |
if ( isset( $value['value'] ) ) { |
| 57 |
$data_column_1[ $key ] = $value['value']; |
| 58 |
} |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
$data_column_2 = is_array( $data['text_list']['column_2'] ) && ! empty( $data['text_list']['column_2'] ) ? $data['text_list']['column_2'] : $data_column_default; |
| 63 |
if ( is_array( $data['text_list']['column_2'] ) && ! empty( $data['text_list']['column_2'] ) ) { |
| 64 |
$_data_column_2 = $data['text_list']['column_2']; |
| 65 |
foreach ( $_data_column_2 as $key => $value ) { |
| 66 |
if ( isset( $value['value'] ) ) { |
| 67 |
$data_column_2[ $key ] = $value['value']; |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
$data_column_3 = is_array( $data['text_list']['column_3'] ) && ! empty( $data['text_list']['column_3'] ) ? $data['text_list']['column_3'] : $data_column_default; |
| 73 |
if ( is_array( $data['text_list']['column_3'] ) && ! empty( $data['text_list']['column_3'] ) ) { |
| 74 |
$_data_column_3 = $data['text_list']['column_3']; |
| 75 |
foreach ( $_data_column_3 as $key => $value ) { |
| 76 |
if ( isset( $value['value'] ) ) { |
| 77 |
$data_column_3[ $key ] = $value['value']; |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
$wrapper_style = TemplateHelpers::get_style( |
| 83 |
[ |
| 84 |
'word-break' => 'break-word', |
| 85 |
'background-color' => $data['background_color'], |
| 86 |
] |
| 87 |
); |
| 88 |
|
| 89 |
$column_width = $container_width / $data['number_column']; |
| 90 |
|
| 91 |
$column_style = TemplateHelpers::get_style( |
| 92 |
[ |
| 93 |
'color' => $data['text_color'], |
| 94 |
'width' => TemplateHelpers::get_dimension_value( $column_width, 'px' ), |
| 95 |
'box-sizing' => 'border-box', |
| 96 |
'display' => 'table-cell', |
| 97 |
'word-break' => 'break-word', |
| 98 |
] |
| 99 |
); |
| 100 |
|
| 101 |
$column_text_style = TemplateHelpers::get_style( |
| 102 |
[ |
| 103 |
'width' => TemplateHelpers::get_dimension_value( 100 / $data['number_column'] ), |
| 104 |
] |
| 105 |
); |
| 106 |
|
| 107 |
$column_1_text_style = TemplateHelpers::get_style( |
| 108 |
[ |
| 109 |
'text-align' => 'left', |
| 110 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data_column_1['padding'] ) ? $data_column_1['padding'] : [] ), |
| 111 |
'font-family' => TemplateHelpers::get_font_family_value( $data_column_1['font_family'] ), |
| 112 |
] |
| 113 |
); |
| 114 |
|
| 115 |
$column_1_button_holder_style = TemplateHelpers::get_style( |
| 116 |
[ |
| 117 |
'width' => TemplateHelpers::get_dimension_value( $data_column_1['button_width'], '%' ), |
| 118 |
'margin' => 'auto', |
| 119 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data_column_1['button_padding'] ) ? $data_column_1['button_padding'] : [] ), |
| 120 |
'float' => in_array( $data_column_1['button_align'], [ 'left', 'right' ], true ) ? $data_column_1['button_align'] : 'unset', |
| 121 |
] |
| 122 |
); |
| 123 |
|
| 124 |
$column_1_button_link_style = TemplateHelpers::get_style( |
| 125 |
[ |
| 126 |
'text-decoration' => 'none', |
| 127 |
'padding' => '12px 20px', |
| 128 |
'display' => 'block', |
| 129 |
'box-sizing' => 'border-box', |
| 130 |
'border-radius' => TemplateHelpers::get_border_radius_value( isset( $data_column_1['button_border_radius'] ) ? $data_column_1['button_border_radius'] : [] ), |
| 131 |
'font-size' => "{$data_column_1['button_font_size']}px", |
| 132 |
'font-weight' => $data_column_1['button_weight'], |
| 133 |
'background-color' => $data_column_1['button_background_color'], |
| 134 |
'word-break' => 'break-word', |
| 135 |
] |
| 136 |
); |
| 137 |
|
| 138 |
$column_1_button_text_style = TemplateHelpers::get_style( |
| 139 |
[ |
| 140 |
'font-family' => TemplateHelpers::get_font_family_value( $data_column_1['button_font_family'] ), |
| 141 |
'line-height' => "{$data_column_1['button_height']}px", |
| 142 |
'color' => $data_column_1['button_text_color'], |
| 143 |
'text-align' => 'center', |
| 144 |
'display' => 'block', |
| 145 |
] |
| 146 |
); |
| 147 |
|
| 148 |
$column_2_text_style = TemplateHelpers::get_style( |
| 149 |
[ |
| 150 |
'text-align' => 'left', |
| 151 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data_column_2['padding'] ) ? $data_column_2['padding'] : [] ), |
| 152 |
'font-family' => TemplateHelpers::get_font_family_value( $data_column_2['font_family'] ), |
| 153 |
] |
| 154 |
); |
| 155 |
|
| 156 |
$column_2_button_holder_style = TemplateHelpers::get_style( |
| 157 |
[ |
| 158 |
'width' => TemplateHelpers::get_dimension_value( $data_column_2['button_width'], '%' ), |
| 159 |
'margin' => 'auto', |
| 160 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data_column_2['button_padding'] ) ? $data_column_2['button_padding'] : [] ), |
| 161 |
'float' => in_array( $data_column_2['button_align'], [ 'left', 'right' ], true ) ? $data_column_2['button_align'] : 'unset', |
| 162 |
] |
| 163 |
); |
| 164 |
|
| 165 |
$column_2_button_link_style = TemplateHelpers::get_style( |
| 166 |
[ |
| 167 |
'text-decoration' => 'none', |
| 168 |
'padding' => '12px 20px', |
| 169 |
'display' => 'block', |
| 170 |
'box-sizing' => 'border-box', |
| 171 |
'border-radius' => TemplateHelpers::get_border_radius_value( isset( $data_column_2['button_border_radius'] ) ? $data_column_2['button_border_radius'] : [] ), |
| 172 |
'font-size' => "{$data_column_2['button_font_size']}px", |
| 173 |
'font-weight' => $data_column_2['button_weight'], |
| 174 |
'background-color' => $data_column_2['button_background_color'], |
| 175 |
'word-break' => 'break-word', |
| 176 |
] |
| 177 |
); |
| 178 |
|
| 179 |
$column_2_button_text_style = TemplateHelpers::get_style( |
| 180 |
[ |
| 181 |
'font-family' => TemplateHelpers::get_font_family_value( $data_column_2['button_font_family'] ), |
| 182 |
'line-height' => "{$data_column_2['button_height']}px", |
| 183 |
'color' => $data_column_2['button_text_color'], |
| 184 |
'text-align' => 'center', |
| 185 |
'display' => 'block', |
| 186 |
] |
| 187 |
); |
| 188 |
|
| 189 |
$column_3_text_style = TemplateHelpers::get_style( |
| 190 |
[ |
| 191 |
'text-align' => 'left', |
| 192 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data_column_3['padding'] ) ? $data_column_3['padding'] : [] ), |
| 193 |
'font-family' => TemplateHelpers::get_font_family_value( $data_column_3['font_family'] ), |
| 194 |
] |
| 195 |
); |
| 196 |
|
| 197 |
$column_3_button_holder_style = TemplateHelpers::get_style( |
| 198 |
[ |
| 199 |
'width' => TemplateHelpers::get_dimension_value( $data_column_3['button_width'], '%' ), |
| 200 |
'margin' => 'auto', |
| 201 |
'padding' => TemplateHelpers::get_spacing_value( isset( $data_column_3['button_padding'] ) ? $data_column_3['button_padding'] : [] ), |
| 202 |
'float' => in_array( $data_column_3['button_align'], [ 'left', 'right' ], true ) ? $data_column_3['button_align'] : 'unset', |
| 203 |
] |
| 204 |
); |
| 205 |
|
| 206 |
$column_3_button_link_style = TemplateHelpers::get_style( |
| 207 |
[ |
| 208 |
'text-decoration' => 'none', |
| 209 |
'padding' => '12px 20px', |
| 210 |
'display' => 'block', |
| 211 |
'box-sizing' => 'border-box', |
| 212 |
'border-radius' => TemplateHelpers::get_border_radius_value( isset( $data_column_3['button_border_radius'] ) ? $data_column_3['button_border_radius'] : [] ), |
| 213 |
'font-size' => "{$data_column_3['button_font_size']}px", |
| 214 |
'font-weight' => $data_column_3['button_weight'], |
| 215 |
'background-color' => $data_column_3['button_background_color'], |
| 216 |
'word-break' => 'break-word', |
| 217 |
] |
| 218 |
); |
| 219 |
|
| 220 |
$column_3_button_text_style = TemplateHelpers::get_style( |
| 221 |
[ |
| 222 |
'font-family' => TemplateHelpers::get_font_family_value( $data_column_3['button_font_family'] ), |
| 223 |
'line-height' => "{$data_column_3['button_height']}px", |
| 224 |
'color' => $data_column_3['button_text_color'], |
| 225 |
'text-align' => 'center', |
| 226 |
'display' => 'block', |
| 227 |
] |
| 228 |
); |
| 229 |
|
| 230 |
ob_start(); |
| 231 |
?> |
| 232 |
|
| 233 |
<table className="yaymail-table-text-list" width="100%" cellspacing="0" cellpadding="0" border="0" style="width: 100%;table-layout: fixed;"> |
| 234 |
<tbody> |
| 235 |
<tr> |
| 236 |
<!-- Column 1 --> |
| 237 |
<td valign="top" style="<?php echo esc_attr( $column_style ); ?>"> |
| 238 |
<table style="width: 100%;table-layout: fixed;"> |
| 239 |
<tbody> |
| 240 |
<tr> |
| 241 |
<td> |
| 242 |
<div class="yaymail-table-text-list-column" style="<?php echo esc_attr( $column_1_text_style ); ?> "> |
| 243 |
<?php echo wp_kses_post( do_shortcode( $data_column_1['rich_text'] ) ); ?> |
| 244 |
</div> |
| 245 |
</td> |
| 246 |
</tr> |
| 247 |
<?php if ( $data_column_1['show_button'] ) : ?> |
| 248 |
<tr> |
| 249 |
<td class="yaymail-table-text-list-column"> |
| 250 |
<table style="<?php echo esc_attr( $column_1_button_holder_style ); ?>"> |
| 251 |
<tbody> |
| 252 |
<tr> |
| 253 |
<td> |
| 254 |
<a |
| 255 |
href="<?php echo esc_url( do_shortcode( $data_column_1['button_url'] ) ); ?>" |
| 256 |
style="<?php echo esc_attr( $column_1_button_link_style ); ?>" |
| 257 |
target="_blank" |
| 258 |
rel="noreferrer" |
| 259 |
> |
| 260 |
<span style="<?php echo esc_attr( $column_1_button_text_style ); ?>"><?php echo esc_html( $data_column_1['button_text'] ); ?></span> |
| 261 |
</a> |
| 262 |
</td> |
| 263 |
</tr> |
| 264 |
</tbody> |
| 265 |
</table> |
| 266 |
</td> |
| 267 |
</tr> |
| 268 |
<?php endif; ?> |
| 269 |
</tbody> |
| 270 |
</table> |
| 271 |
</td> |
| 272 |
<!-- Column 2 --> |
| 273 |
<?php if ( 1 < (int) $data['number_column'] ) : ?> |
| 274 |
<td valign="top" style="<?php echo esc_attr( $column_style ); ?>"> |
| 275 |
<table style="width: 100%;table-layout: fixed;"> |
| 276 |
<tbody> |
| 277 |
<tr> |
| 278 |
<td> |
| 279 |
<div class="yaymail-table-text-list-column" style="<?php echo esc_attr( $column_2_text_style ); ?>"> |
| 280 |
<?php echo wp_kses_post( do_shortcode( $data_column_2['rich_text'] ) ); ?> |
| 281 |
</div> |
| 282 |
</td> |
| 283 |
</tr> |
| 284 |
<?php if ( $data_column_2['show_button'] ) : ?> |
| 285 |
<tr> |
| 286 |
<td class="yaymail-table-text-list-column"> |
| 287 |
<table style="<?php echo esc_attr( $column_2_button_holder_style ); ?>"> |
| 288 |
<tbody> |
| 289 |
<tr> |
| 290 |
<td> |
| 291 |
<a |
| 292 |
href="<?php echo esc_url( do_shortcode( $data_column_2['button_url'] ) ); ?>" |
| 293 |
style="<?php echo esc_attr( $column_2_button_link_style ); ?>" |
| 294 |
target="_blank" |
| 295 |
rel="noreferrer" |
| 296 |
> |
| 297 |
<span style="<?php echo esc_attr( $column_2_button_text_style ); ?>"><?php echo esc_html( $data_column_2['button_text'] ); ?></span> |
| 298 |
</a> |
| 299 |
</td> |
| 300 |
</tr> |
| 301 |
</tbody> |
| 302 |
</table> |
| 303 |
</td> |
| 304 |
</tr> |
| 305 |
<?php endif; ?> |
| 306 |
</tbody> |
| 307 |
</table> |
| 308 |
</td> |
| 309 |
<?php endif; ?> |
| 310 |
<!-- Column 3 --> |
| 311 |
<?php if ( 3 === (int) $data['number_column'] ) : ?> |
| 312 |
<td valign="top" style="<?php echo esc_attr( $column_style ); ?>"> |
| 313 |
<table style="width: 100%;table-layout: fixed;"> |
| 314 |
<tbody> |
| 315 |
<tr> |
| 316 |
<td> |
| 317 |
<div style="<?php echo esc_attr( $column_3_text_style ); ?>"> |
| 318 |
<?php echo wp_kses_post( do_shortcode( $data_column_3['rich_text'] ) ); ?> |
| 319 |
</div> |
| 320 |
</td> |
| 321 |
</tr> |
| 322 |
<?php if ( $data_column_3['show_button'] ) : ?> |
| 323 |
<tr> |
| 324 |
<td> |
| 325 |
<table style="<?php echo esc_attr( $column_3_button_holder_style ); ?>"> |
| 326 |
<tbody> |
| 327 |
<tr> |
| 328 |
<td> |
| 329 |
<a |
| 330 |
href="<?php echo esc_url( do_shortcode( $data_column_3['button_url'] ) ); ?>" |
| 331 |
style="<?php echo esc_attr( $column_3_button_link_style ); ?>" |
| 332 |
target="_blank" |
| 333 |
rel="noreferrer" |
| 334 |
> |
| 335 |
<span style="<?php echo esc_attr( $column_3_button_text_style ); ?>"><?php echo esc_html( $data_column_3['button_text'] ); ?></span> |
| 336 |
</a> |
| 337 |
</td> |
| 338 |
</tr> |
| 339 |
</tbody> |
| 340 |
</table> |
| 341 |
</td> |
| 342 |
</tr> |
| 343 |
<?php endif; ?> |
| 344 |
</tbody> |
| 345 |
</table> |
| 346 |
</td> |
| 347 |
<?php endif; ?> |
| 348 |
</tbody> |
| 349 |
</table> |
| 350 |
<?php |
| 351 |
$element_content = ob_get_clean(); |
| 352 |
|
| 353 |
TemplateHelpers::wrap_element_content( $element_content, $element, $wrapper_style ); |
| 354 |
|