PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.2
YayMail – WooCommerce Email Customizer v4.4.2
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.2, at templates/elements/order-progress/variants/filled-bar.php

316 lines 19.1 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 ]
121 );
122
123 $pill_outer_px = (int) ( $icon_size + ( $pill_padding_px * 2 ) + ( max( 0, (int) $icon_border_width ) * 2 ) );
124 $marker_cell_w = $show_icon_pill ? max( $bubble_cell_size, $pill_outer_px ) : $small_dot_px;
125
126 $small_dot_style = TemplateHelpers::get_style(
127 [
128 'width' => $small_dot_px . 'px',
129 'height' => $small_dot_px . 'px',
130 'border-radius' => ( (int) ( $small_dot_px / 2 ) ) . 'px',
131 'background-color' => $plain_dot_fill,
132 'margin' => '0 auto',
133 'font-size' => '0',
134 'line-height' => '0',
135 'outline' => '3px solid #ffffff',
136 ]
137 );
138
139 $icon_middle_td_style = TemplateHelpers::get_style(
140 [
141 'vertical-align' => 'middle',
142 'padding' => '0',
143 'text-align' => 'center',
144 'line-height' => '0 !important',
145 ]
146 );
147 ?>
148 <td width="<?php echo esc_attr( (string) $pct ); ?>%" align="center" valign="middle" style="
149 <?php
150 echo esc_attr(
151 TemplateHelpers::get_style(
152 [
153 'width' => $pct . '%',
154 'vertical-align' => 'middle',
155 'padding' => '0',
156 'padding-left' => '0',
157 'padding-right' => '0',
158 'text-align' => 'center',
159 'line-height' => '0',
160 'font-size' => '0',
161 ]
162 )
163 );
164 ?>
165 ">
166 <table width="100%" cellpadding="0" cellspacing="0" role="presentation" style="<?php echo esc_attr( TemplateHelpers::get_style( [ 'border-collapse' => 'collapse' ] ) ); ?>">
167 <tbody>
168 <tr>
169 <?php if ( 0 !== (int) $index ) : ?>
170 <td valign="middle" style="
171 <?php
172 echo esc_attr(
173 TemplateHelpers::get_style(
174 [
175 'vertical-align' => 'middle',
176 'padding' => '0',
177 'padding-right' => $connector_gap_px . 'px',
178 ]
179 )
180 );
181 ?>
182 ">
183 <div style="
184 <?php
185 echo esc_attr(
186 TemplateHelpers::get_style(
187 [
188 'height' => $bar_height . 'px',
189 'background-color' => $left_color,
190 'width' => '100%',
191 'font-size' => '0',
192 'line-height' => '0',
193 ]
194 )
195 );
196 ?>
197 ">&nbsp;</div>
198 </td>
199 <?php endif; ?>
200
201 <td width="<?php echo esc_attr( (string) $marker_cell_w ); ?>" align="center" valign="middle" style="<?php echo esc_attr( $icon_middle_td_style ); ?>">
202 <?php if ( $show_icon_pill ) : ?>
203 <span style="<?php echo esc_attr( $icon_wrap_style ); ?>">
204 <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 ); ?>"/>
205 </span>
206 <?php else : ?>
207 <div style="<?php echo esc_attr( $small_dot_style ); ?>">&nbsp;</div>
208 <?php endif; ?>
209 </td>
210
211 <?php if ( (int) $index !== $step_count - 1 ) : ?>
212 <td valign="middle" style="
213 <?php
214 echo esc_attr(
215 TemplateHelpers::get_style(
216 [
217 'vertical-align' => 'middle',
218 'padding' => '0',
219 'padding-left' => $connector_gap_px . 'px',
220 ]
221 )
222 );
223 ?>
224 ">
225 <div style="
226 <?php
227 echo esc_attr(
228 TemplateHelpers::get_style(
229 [
230 'height' => $bar_height . 'px',
231 'background-color' => $right_color,
232 'width' => '100%',
233 'font-size' => '0',
234 'line-height' => '0',
235 ]
236 )
237 );
238 ?>
239 ">&nbsp;</div>
240 </td>
241 <?php endif; ?>
242 </tr>
243 </tbody>
244 </table>
245 </td>
246 <?php endforeach; ?>
247 </tr>
248 </tbody>
249 </table>
250 </td>
251 </tr>
252
253 <tr class="yaymail-element-order-progress--filled-bar-labels-row">
254 <td colspan="<?php echo esc_attr( (string) $step_count ); ?>" style="<?php echo esc_attr( TemplateHelpers::get_style( [ 'padding' => '0' ] ) ); ?>">
255 <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 ); ?>">
256 <tbody>
257 <tr>
258 <?php foreach ( $display_steps as $index => $step ) : ?>
259 <?php
260 $is_step_active = $index <= $active_index;
261
262 $title = is_array( $step ) ? (string) ( $step['title'] ?? $step['label'] ?? '' ) : '';
263
264 // Mirror filled-bar.tsx: first column left, last right, else center.
265 $label_td_align = ( 0 === (int) $index )
266 ? 'left'
267 : ( (int) $index === $step_count - 1 ? 'right' : 'center' );
268
269 $label_color = OrderProgressVariantHelpers::get_step_label_color(
270 is_array( $step ) ? $step : [],
271 $is_step_active,
272 $legacy_label_active_color,
273 $legacy_label_inactive_color
274 );
275
276 $label_pct = isset( $column_width_percents[ $index ] ) ? (int) $column_width_percents[ $index ] : (int) floor( 100 / max( 1, $step_count ) );
277
278 $label_style = TemplateHelpers::get_style(
279 [
280 'margin' => '8px 0 0',
281 'padding' => '0',
282 'font-size' => $label_font_size . 'px',
283 'line-height' => '1.2',
284 'color' => $label_color,
285 'font-family' => $label_font_family,
286 ]
287 );
288 ?>
289 <td width="<?php echo esc_attr( (string) $label_pct ); ?>%" align="center" style="
290 <?php
291 echo esc_attr(
292 TemplateHelpers::get_style(
293 [
294 'width' => $label_pct . '%',
295 'vertical-align' => 'top',
296 'padding' => '0',
297 'text-align' => $label_td_align,
298 ]
299 )
300 );
301 ?>
302 ">
303 <?php if ( '' !== $title ) : ?>
304 <p style="<?php echo esc_attr( $label_style ); ?>"><?php echo esc_html( $title ); ?></p>
305 <?php endif; ?>
306 </td>
307 <?php endforeach; ?>
308 </tr>
309 </tbody>
310 </table>
311 </td>
312 </tr>
313 </tbody>
314 </table>
315
316