← All changes
|
templates/elements/order-progress/variants/filled-bar.php
+64
-47
4.4.1
→
4.4.6
View file →
| @@ -21,9 +21,9 @@ | ||
| 21 | 21 | $element = $args['element']; |
| 22 | 22 | $data = $element['data']; |
| 23 | 23 | |
| 24 | 24 | $yaymail_op_max_steps = 5; |
| 25 | -$display_steps = array_slice( $steps, 0, $yaymail_op_max_steps ); | |
| 25 | +$display_steps = array_values( array_slice( $steps, 0, $yaymail_op_max_steps ) ); | |
| 26 | 26 | $step_count = count( $display_steps ); |
| 27 | 27 | |
| 28 | 28 | if ( $step_count < 1 ) { |
| 29 | 29 | return; |
| @@ -30,11 +30,12 @@ | ||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | $active_index = min( max( 0, (int) $current_step_index ), max( 0, $step_count - 1 ) ); |
| 33 | 33 | |
| 34 | -$bubble_pad = 6; | |
| 35 | -$bubble_size = $icon_size + ( $bubble_pad * 2 ); | |
| 36 | -$bubble_cell_size = max( 44, $bubble_size ); | |
| 34 | +$pill_padding_px = 10; | |
| 35 | +$bubble_cell_size = 44; | |
| 36 | +$small_dot_px = 14; | |
| 37 | +$connector_gap_px = 8; | |
| 37 | 38 | |
| 38 | 39 | // Connector bar: at least 1px (customizer clamps connector_height to 1–10). |
| 39 | 40 | $bar_height = max( 1, (int) $connector_height ); |
| 40 | 41 | |
| @@ -51,35 +52,37 @@ | ||
| 51 | 52 | <tbody> |
| 52 | 53 | <tr> |
| 53 | 54 | <?php foreach ( $display_steps as $index => $step ) : ?> |
| 54 | 55 | <?php |
| 55 | - $is_step_active = $index <= $active_index; | |
| 56 | + $step_index = (int) $index; | |
| 57 | + $is_step_active = $step_index <= $active_index; | |
| 58 | + $step_array = is_array( $step ) ? $step : []; | |
| 56 | 59 | |
| 57 | - $image_active_url = is_array( $step ) ? (string) ( $step['image_active_url'] ?? '' ) : ''; | |
| 58 | - $image_inactive_url = is_array( $step ) ? (string) ( $step['image_inactive_url'] ?? '' ) : ''; | |
| 60 | + $image_url = OrderProgressVariantHelpers::get_step_image_url( $step_array ); | |
| 61 | + $show_icon_pill = '' !== $image_url; | |
| 59 | 62 | |
| 60 | - $image_url = OrderProgressVariantHelpers::resolve_step_image_url( $is_step_active, $image_active_url, $image_inactive_url ); | |
| 61 | - | |
| 62 | 63 | $raw_image_bg_color = is_array( $step ) ? (string) ( $step['image_bg_color'] ?? '' ) : ''; |
| 63 | - $image_bg_color = OrderProgressVariantHelpers::resolve_filled_bar_icon_background( | |
| 64 | - $is_step_active, | |
| 65 | - $raw_image_bg_color, | |
| 66 | - $connector_active_color | |
| 67 | - ); | |
| 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 | + } | |
| 68 | 72 | |
| 69 | 73 | $raw_global_border_radius = is_array( $data ) ? (string) ( $data['filled_bar_icon_border_radius'] ?? '' ) : ''; |
| 70 | - $raw_border_active = is_array( $step ) ? (string) ( $step['filled_bar_icon_border_color_active'] ?? '' ) : ''; | |
| 71 | - $raw_border_inactive = is_array( $step ) ? (string) ( $step['filled_bar_icon_border_color_inactive'] ?? '' ) : ''; | |
| 72 | 74 | $icon_border_radius = trim( (string) $raw_global_border_radius ) === '' |
| 73 | 75 | ? 50 |
| 74 | 76 | : max( 0, (int) $raw_global_border_radius ); |
| 75 | 77 | |
| 76 | - $icon_border_color = OrderProgressVariantHelpers::resolve_filled_bar_icon_border_color( | |
| 77 | - $is_step_active, | |
| 78 | - $raw_border_active, | |
| 79 | - $raw_border_inactive | |
| 80 | - ); | |
| 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']; | |
| 81 | 82 | |
| 83 | + $plain_dot_fill = $is_step_active ? $connector_active_color : $connector_inactive_color; | |
| 84 | + | |
| 82 | 85 | $pct = isset( $column_width_percents[ $index ] ) ? (int) $column_width_percents[ $index ] : (int) floor( 100 / max( 1, $step_count ) ); |
| 83 | 86 | |
| 84 | 87 | $segment_colors = OrderProgressVariantHelpers::get_connector_segment_colors( |
| 85 | 88 | $index, |
| @@ -97,14 +100,44 @@ | ||
| 97 | 100 | 'background-color' => $image_bg_color ? $image_bg_color : 'transparent', |
| 98 | 101 | 'border-radius' => $icon_border_radius . 'px', |
| 99 | 102 | 'padding' => '10px', |
| 100 | 103 | 'vertical-align' => 'middle', |
| 101 | - 'border-width' => '2px', | |
| 102 | - 'border-style' => 'solid', | |
| 104 | + 'border-width' => $icon_border_width . 'px', | |
| 105 | + 'border-style' => $icon_border_style, | |
| 103 | 106 | 'border-color' => $icon_border_color, |
| 104 | 107 | ] |
| 105 | 108 | ); |
| 106 | 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 | + | |
| 107 | 140 | $icon_middle_td_style = TemplateHelpers::get_style( |
| 108 | 141 | [ |
| 109 | 142 | 'vertical-align' => 'middle', |
| 110 | 143 | 'padding' => '0', |
| @@ -141,8 +174,9 @@ | ||
| 141 | 174 | TemplateHelpers::get_style( |
| 142 | 175 | [ |
| 143 | 176 | 'vertical-align' => 'middle', |
| 144 | 177 | 'padding' => '0', |
| 178 | + 'padding-right' => $connector_gap_px . 'px', | |
| 145 | 179 | ] |
| 146 | 180 | ) |
| 147 | 181 | ); |
| 148 | 182 | ?> |
| @@ -164,27 +198,15 @@ | ||
| 164 | 198 | "> </div> |
| 165 | 199 | </td> |
| 166 | 200 | <?php endif; ?> |
| 167 | 201 | |
| 168 | - <td width="50" align="center" valign="middle" style="<?php echo esc_attr( $icon_middle_td_style ); ?>"> | |
| 169 | - <?php if ( ! empty( $image_url ) ) : ?> | |
| 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 ) : ?> | |
| 170 | 204 | <span style="<?php echo esc_attr( $icon_wrap_style ); ?>"> |
| 171 | - <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="display:block;margin:0 auto;border:0;outline:none;text-decoration:none;width:<?php echo esc_attr( (string) $icon_size ); ?>px;height:<?php echo esc_attr( (string) $icon_size ); ?>px;"/> | |
| 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 ); ?>"/> | |
| 172 | 206 | </span> |
| 173 | 207 | <?php else : ?> |
| 174 | - <span style=" | |
| 175 | - <?php | |
| 176 | - echo esc_attr( | |
| 177 | - TemplateHelpers::get_style( | |
| 178 | - [ | |
| 179 | - 'display' => 'inline-block', | |
| 180 | - 'width' => $bubble_cell_size . 'px', | |
| 181 | - 'min-height' => $bubble_cell_size . 'px', | |
| 182 | - ] | |
| 183 | - ) | |
| 184 | - ); | |
| 185 | - ?> | |
| 186 | - "> </span> | |
| 208 | + <div style="<?php echo esc_attr( $small_dot_style ); ?>"> </div> | |
| 187 | 209 | <?php endif; ?> |
| 188 | 210 | </td> |
| 189 | 211 | |
| 190 | 212 | <?php if ( (int) $index !== $step_count - 1 ) : ?> |
| @@ -194,8 +216,9 @@ | ||
| 194 | 216 | TemplateHelpers::get_style( |
| 195 | 217 | [ |
| 196 | 218 | 'vertical-align' => 'middle', |
| 197 | 219 | 'padding' => '0', |
| 220 | + 'padding-left' => $connector_gap_px . 'px', | |
| 198 | 221 | ] |
| 199 | 222 | ) |
| 200 | 223 | ); |
| 201 | 224 | ?> |
| @@ -238,22 +261,16 @@ | ||
| 238 | 261 | $is_step_active = $index <= $active_index; |
| 239 | 262 | |
| 240 | 263 | $title = is_array( $step ) ? (string) ( $step['title'] ?? $step['label'] ?? '' ) : ''; |
| 241 | 264 | |
| 242 | - $step_label_color = is_array( $step ) ? (string) ( $step['label_color'] ?? '' ) : ''; | |
| 243 | - $step_label_active_color = is_array( $step ) ? (string) ( $step['label_active_color'] ?? '' ) : ''; | |
| 244 | - $step_label_inactive_color = is_array( $step ) ? (string) ( $step['label_inactive_color'] ?? '' ) : ''; | |
| 245 | - | |
| 246 | 265 | // Mirror filled-bar.tsx: first column left, last right, else center. |
| 247 | 266 | $label_td_align = ( 0 === (int) $index ) |
| 248 | 267 | ? 'left' |
| 249 | 268 | : ( (int) $index === $step_count - 1 ? 'right' : 'center' ); |
| 250 | 269 | |
| 251 | - $label_color = OrderProgressVariantHelpers::resolve_filled_bar_label_color( | |
| 252 | - $step_label_color, | |
| 270 | + $label_color = OrderProgressVariantHelpers::get_step_label_color( | |
| 271 | + is_array( $step ) ? $step : [], | |
| 253 | 272 | $is_step_active, |
| 254 | - $step_label_active_color, | |
| 255 | - $step_label_inactive_color, | |
| 256 | 273 | $legacy_label_active_color, |
| 257 | 274 | $legacy_label_inactive_color |
| 258 | 275 | ); |
| 259 | 276 | |