PluginProbe
YayMail – WooCommerce Email Customizer / trunk
YayMail – WooCommerce Email Customizer vtrunk
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / templates / elements / image-box.php

image-box.php in YayMail – WooCommerce Email Customizer trunk, at templates/elements/image-box.php

107 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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
12 $data_column_1 = [
13 'align' => 'center',
14 'full_width' => false,
15 'width' => '242',
16 'url' => '#',
17 'image' => YAYMAIL_PLUGIN_URL . 'assets/images/woocommerce-logo.png',
18 'padding' => [
19 'top' => '10',
20 'right' => '10',
21 'bottom' => '10',
22 'left' => '50',
23 ],
24 ];
25
26 if ( is_array( $data['image_box']['column_1'] ) && ! empty( $data['image_box']['column_1'] ) ) {
27 $_data_column_1 = $data['image_box']['column_1'];
28 foreach ( $_data_column_1 as $key => $value ) {
29 if ( $key === 'full_width' ) {
30 $data_column_1['full_width'] = filter_var( $value['value'], FILTER_VALIDATE_BOOLEAN );
31 } else {
32 $data_column_1[ $key ] = $value['value'];
33 }
34 }
35 }
36
37 $data_column_2 = [
38 'rich_text' => '<p><span style="font-size: 18px;"><strong>This is a title</strong></span></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><span>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.</span></p>',
39 'font_family' => YAYMAIL_DEFAULT_FAMILY,
40 'padding' => [
41 'top' => '10',
42 'right' => '50',
43 'bottom' => '10',
44 'left' => '10',
45 ],
46 ];
47
48 if ( is_array( $data['image_box']['column_2'] ) && ! empty( $data['image_box']['column_2'] ) ) {
49 $_data_column_2 = $data['image_box']['column_2'];
50 foreach ( $_data_column_2 as $key => $value ) {
51 $data_column_2[ $key ] = $value['value'];
52 }
53 }
54
55 $wrapper_style = TemplateHelpers::get_style(
56 [
57 'word-break' => 'break-word',
58 'background-color' => $data['background_color'],
59 ]
60 );
61
62 $column_1_style = TemplateHelpers::get_style(
63 [
64 'padding' => TemplateHelpers::get_spacing_value( isset( $data_column_1['padding'] ) ? $data_column_1['padding'] : [] ),
65 ]
66 );
67
68 $column_2_style = TemplateHelpers::get_style(
69 [
70 'padding' => TemplateHelpers::get_spacing_value( isset( $data_column_2['padding'] ) ? $data_column_2['padding'] : [] ),
71 ]
72 );
73
74
75 $text_style = TemplateHelpers::get_style(
76 [
77 'color' => $data['text_color'],
78 'text-align' => 'left',
79 'font-family' => TemplateHelpers::get_font_family_value( $data_column_2['font_family'] ),
80 ]
81 );
82
83 ob_start();
84 ?>
85 <table style="width: 100%;">
86 <tbody>
87 <tr>
88 <td class="yaymail-table-image-box-column" align="<?php echo esc_attr( $data_column_1['align'] ); ?>" width="50%" style="<?php echo esc_attr( $column_1_style ); ?>">
89 <div>
90 <a href="<?php echo esc_html( do_shortcode( $data_column_1['url'] ) ); ?>" target="_blank" rel="noreferrer">
91 <img alt="<?php echo esc_attr( $data_column_1['alt'] ?? '' ); ?>" src="<?php echo esc_html( $data_column_1['image'] ); ?>" style="width: <?php echo esc_attr( isset( $data_column_1['full_width'] ) && $data_column_1['full_width'] ? '100%' : TemplateHelpers::get_dimension_value( $data_column_1['width'] ) ); ?>"/>
92 </a>
93 </div>
94 </td>
95 <td class="yaymail-table-image-box-column" width="50%" style="<?php echo esc_attr( $column_2_style ); ?>" >
96 <div style="<?php echo esc_attr( $text_style ); ?>">
97 <?php echo wp_kses_post( do_shortcode( $data_column_2['rich_text'] ) ); ?>
98 </div>
99 </td>
100 </tr>
101 </tbody>
102 </table>
103 <?php
104 $element_content = ob_get_clean();
105
106 TemplateHelpers::wrap_element_content( $element_content, $element, $wrapper_style );
107