PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
4.4.6 4.4.5 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 All 57 releases
yaymail / templates / elements / order-progress / variants / filled-bar.php

filled-bar.php in YayMail – WooCommerce Email Customizer 4.4.5, at templates/elements/order-progress/variants/filled-bar.php

317 lines 19.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Filled bar variant for Order Progress.
4 *
5 * Variables expected from parent template:
6 * - $steps, $current_step_index, $align, $table_style
7 * - $connector_height, $connector_active_color, $connector_inactive_color
8 * - $icon_size, $label_font_size, $label_font_family
9 * - $legacy_label_active_color, $legacy_label_inactive_color
10 */
11
12 defined( 'ABSPATH' ) || exit;
13
14 use YayMail\Utils\OrderProgressVariantHelpers;
15 use YayMail\Utils\TemplateHelpers;
16
17 if ( empty( $args['element'] ) ) {
18 return;
19 }
20
21 $element = $args['element'];
22 $data = $element['data'];
23
24 $yaymail_op_max_steps = 5;
25 $display_steps = array_values( array_slice( $steps, 0, $yaymail_op_max_steps ) );
26 $step_count = count( $display_steps );
27
28 if ( $step_count < 1 ) {
29 return;
30 }
31
32 $active_index = min( max( 0, (int) $current_step_index ), max( 0, $step_count - 1 ) );
33
34 $pill_padding_px = 10;
35 $bubble_cell_size = 44;
36 $small_dot_px = 14;
37 $connector_gap_px = 8;
38
39 // Connector bar: at least 1px (customizer clamps connector_height to 1–10).
40 $bar_height = max( 1, (int) $connector_height );
41
42 $yaymail_step_marker_presets = OrderProgressVariantHelpers::get_step_marker_presets();
43
44 $preset_key = min( 5, max( 1, $step_count ) );
45 $column_width_percents = $yaymail_step_marker_presets[ $preset_key ]['widths'];
46 ?>
47 <table class="yaymail-element-order-progress yaymail-element-order-progress--filled-bar" width="100%" cellpadding="0" cellspacing="0" role="presentation" style="<?php echo esc_attr( $table_style ); ?>">
48 <tbody>
49 <tr class="yaymail-element-order-progress--filled-bar-track-row">
50 <td colspan="<?php echo esc_attr( (string) $step_count ); ?>" style="<?php echo esc_attr( TemplateHelpers::get_style( [ 'padding' => '0' ] ) ); ?>">
51 <table class="yaymail-element-order-progress--step-marker-track-inner yaymail-element-order-progress--filled-bar-track-inner" width="100%" cellpadding="0" cellspacing="0" role="presentation" style="<?php echo esc_attr( $table_style ); ?>">
52 <tbody>
53 <tr>
54 <?php foreach ( $display_steps as $index => $step ) : ?>
55 <?php
56 $step_index = (int) $index;
57 $is_step_active = $step_index <= $active_index;
58 $step_array = is_array( $step ) ? $step : [];
59
60 $image_url = OrderProgressVariantHelpers::get_step_image_url( $step_array );
61 $show_icon_pill = '' !== $image_url;
62
63 $raw_image_bg_color = is_array( $step ) ? (string) ( $step['image_bg_color'] ?? '' ) : '';
64 $trimmed_bg = trim( $raw_image_bg_color );
65 if ( '' !== $trimmed_bg ) {
66 $image_bg_color = $trimmed_bg;
67 } elseif ( $is_step_active ) {
68 $image_bg_color = $connector_active_color;
69 } else {
70 $image_bg_color = $connector_inactive_color;
71 }
72
73 $raw_global_border_radius = is_array( $data ) ? (string) ( $data['filled_bar_icon_border_radius'] ?? '' ) : '';
74 $icon_border_radius = trim( (string) $raw_global_border_radius ) === ''
75 ? 50
76 : max( 0, (int) $raw_global_border_radius );
77
78 $step_icon_border = OrderProgressVariantHelpers::get_step_icon_border( $step_array );
79 $icon_border_color = $step_icon_border['color'];
80 $icon_border_style = $step_icon_border['style'];
81 $icon_border_width = $step_icon_border['width_px'];
82
83 $plain_dot_fill = $is_step_active ? $connector_active_color : $connector_inactive_color;
84
85 $pct = isset( $column_width_percents[ $index ] ) ? (int) $column_width_percents[ $index ] : (int) floor( 100 / max( 1, $step_count ) );
86
87 $segment_colors = OrderProgressVariantHelpers::get_connector_segment_colors(
88 $index,
89 $active_index,
90 $step_count,
91 $connector_active_color,
92 $connector_inactive_color
93 );
94 $left_color = $segment_colors['left'];
95 $right_color = $segment_colors['right'];
96
97 $icon_wrap_style = TemplateHelpers::get_style(
98 [
99 'display' => 'inline-block',
100 'background-color' => $image_bg_color ? $image_bg_color : 'transparent',
101 'border-radius' => $icon_border_radius . 'px',
102 'padding' => '10px',
103 'vertical-align' => 'middle',
104 'border-width' => $icon_border_width . 'px',
105 'border-style' => $icon_border_style,
106 'border-color' => $icon_border_color,
107 ]
108 );
109
110 $icon_img_style = TemplateHelpers::get_style(
111 [
112 'display' => 'block',
113 'margin' => '0 auto',
114 'border' => '0',
115 'outline' => 'none',
116 'text-decoration' => 'none',
117 'width' => $icon_size . 'px',
118 'height' => $icon_size . 'px',
119 'opacity' => $is_step_active ? '1' : '0.55',
120 'object-fit' => 'contain',
121 ]
122 );
123
124 $pill_outer_px = (int) ( $icon_size + ( $pill_padding_px * 2 ) + ( max( 0, (int) $icon_border_width ) * 2 ) );
125 $marker_cell_w = $show_icon_pill ? max( $bubble_cell_size, $pill_outer_px ) : $small_dot_px;
126
127 $small_dot_style = TemplateHelpers::get_style(
128 [
129 'width' => $small_dot_px . 'px',
130 'height' => $small_dot_px . 'px',
131 'border-radius' => ( (int) ( $small_dot_px / 2 ) ) . 'px',
132 'background-color' => $plain_dot_fill,
133 'margin' => '0 auto',
134 'font-size' => '0',
135 'line-height' => '0',
136 'outline' => '3px solid #ffffff',
137 ]
138 );
139
140 $icon_middle_td_style = TemplateHelpers::get_style(
141 [
142 'vertical-align' => 'middle',
143 'padding' => '0',
144 'text-align' => 'center',
145 'line-height' => '0 !important',
146 ]
147 );
148 ?>
149 <td width="<?php echo esc_attr( (string) $pct ); ?>%" align="center" valign="middle" style="
150 <?php
151 echo esc_attr(
152 TemplateHelpers::get_style(
153 [
154 'width' => $pct . '%',
155 'vertical-align' => 'middle',
156 'padding' => '0',
157 'padding-left' => '0',
158 'padding-right' => '0',
159 'text-align' => 'center',
160 'line-height' => '0',
161 'font-size' => '0',
162 ]
163 )
164 );
165 ?>
166 ">
167 <table width="100%" cellpadding="0" cellspacing="0" role="presentation" style="<?php echo esc_attr( TemplateHelpers::get_style( [ 'border-collapse' => 'collapse' ] ) ); ?>">
168 <tbody>
169 <tr>
170 <?php if ( 0 !== (int) $index ) : ?>
171 <td valign="middle" style="
172 <?php
173 echo esc_attr(
174 TemplateHelpers::get_style(
175 [
176 'vertical-align' => 'middle',
177 'padding' => '0',
178 'padding-right' => $connector_gap_px . 'px',
179 ]
180 )
181 );
182 ?>
183 ">
184 <div style="
185 <?php
186 echo esc_attr(
187 TemplateHelpers::get_style(
188 [
189 'height' => $bar_height . 'px',
190 'background-color' => $left_color,
191 'width' => '100%',
192 'font-size' => '0',
193 'line-height' => '0',
194 ]
195 )
196 );
197 ?>
198 ">&nbsp;</div>
199 </td>
200 <?php endif; ?>
201
202 <td width="<?php echo esc_attr( (string) $marker_cell_w ); ?>" align="center" valign="middle" style="<?php echo esc_attr( $icon_middle_td_style ); ?>">
203 <?php if ( $show_icon_pill ) : ?>
204 <span style="<?php echo esc_attr( $icon_wrap_style ); ?>">
205 <img src="<?php echo esc_url( $image_url ); ?>" alt="" width="<?php echo esc_attr( (string) $icon_size ); ?>" height="<?php echo esc_attr( (string) $icon_size ); ?>" style="<?php echo esc_attr( $icon_img_style ); ?>"/>
206 </span>
207 <?php else : ?>
208 <div style="<?php echo esc_attr( $small_dot_style ); ?>">&nbsp;</div>
209 <?php endif; ?>
210 </td>
211
212 <?php if ( (int) $index !== $step_count - 1 ) : ?>
213 <td valign="middle" style="
214 <?php
215 echo esc_attr(
216 TemplateHelpers::get_style(
217 [
218 'vertical-align' => 'middle',
219 'padding' => '0',
220 'padding-left' => $connector_gap_px . 'px',
221 ]
222 )
223 );
224 ?>
225 ">
226 <div style="
227 <?php
228 echo esc_attr(
229 TemplateHelpers::get_style(
230 [
231 'height' => $bar_height . 'px',
232 'background-color' => $right_color,
233 'width' => '100%',
234 'font-size' => '0',
235 'line-height' => '0',
236 ]
237 )
238 );
239 ?>
240 ">&nbsp;</div>
241 </td>
242 <?php endif; ?>
243 </tr>
244 </tbody>
245 </table>
246 </td>
247 <?php endforeach; ?>
248 </tr>
249 </tbody>
250 </table>
251 </td>
252 </tr>
253
254 <tr class="yaymail-element-order-progress--filled-bar-labels-row">
255 <td colspan="<?php echo esc_attr( (string) $step_count ); ?>" style="<?php echo esc_attr( TemplateHelpers::get_style( [ 'padding' => '0' ] ) ); ?>">
256 <table class="yaymail-element-order-progress--filled-bar-labels-inner" width="100%" cellpadding="0" cellspacing="0" role="presentation" style="<?php echo esc_attr( $table_style ); ?>">
257 <tbody>
258 <tr>
259 <?php foreach ( $display_steps as $index => $step ) : ?>
260 <?php
261 $is_step_active = $index <= $active_index;
262
263 $title = is_array( $step ) ? (string) ( $step['title'] ?? $step['label'] ?? '' ) : '';
264
265 // Mirror filled-bar.tsx: first column left, last right, else center.
266 $label_td_align = ( 0 === (int) $index )
267 ? 'left'
268 : ( (int) $index === $step_count - 1 ? 'right' : 'center' );
269
270 $label_color = OrderProgressVariantHelpers::get_step_label_color(
271 is_array( $step ) ? $step : [],
272 $is_step_active,
273 $legacy_label_active_color,
274 $legacy_label_inactive_color
275 );
276
277 $label_pct = isset( $column_width_percents[ $index ] ) ? (int) $column_width_percents[ $index ] : (int) floor( 100 / max( 1, $step_count ) );
278
279 $label_style = TemplateHelpers::get_style(
280 [
281 'margin' => '8px 0 0',
282 'padding' => '0',
283 'font-size' => $label_font_size . 'px',
284 'line-height' => '1.2',
285 'color' => $label_color,
286 'font-family' => $label_font_family,
287 ]
288 );
289 ?>
290 <td width="<?php echo esc_attr( (string) $label_pct ); ?>%" align="center" style="
291 <?php
292 echo esc_attr(
293 TemplateHelpers::get_style(
294 [
295 'width' => $label_pct . '%',
296 'vertical-align' => 'top',
297 'padding' => '0',
298 'text-align' => $label_td_align,
299 ]
300 )
301 );
302 ?>
303 ">
304 <?php if ( '' !== $title ) : ?>
305 <p style="<?php echo esc_attr( $label_style ); ?>"><?php echo esc_html( $title ); ?></p>
306 <?php endif; ?>
307 </td>
308 <?php endforeach; ?>
309 </tr>
310 </tbody>
311 </table>
312 </td>
313 </tr>
314 </tbody>
315 </table>
316
317