1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?php
defined( 'ABSPATH' ) || exit;
use YayMail\Utils\TemplateHelpers;
if ( empty( $args['element'] ) ) { return; }
$element = $args['element']; $data = $element['data'];
$wrapper_style = TemplateHelpers::get_style( [ 'word-break' => 'break-word', 'text-align' => $data['align'] ?? 'center', 'background-color' => $data['background_color'] ?? '#fff', 'padding' => TemplateHelpers::get_spacing_value( isset( $data['padding'] ) ? $data['padding'] : [] ), ] );
$table_style = TemplateHelpers::get_style( [ 'display' => 'inline-table', 'border-collapse' => 'collapse', ] );
$active_stars = min( $data['active_stars'] ?? 5, $data['total_stars'] ?? 5 ); $total_stars = $data['total_stars'] ?? 5; $size = $data['size'] ?? 40; $spacing = $data['spacing'] ?? 10; $active_color = $data['active_stars_color'] ?? '#FFD700'; $inactive_color = $data['inactive_stars_color'] ?? '#E0E0E0';
ob_start(); ?> <table class="yaymail-customizer-element-rating-stars" cellpadding="0" cellspacing="0" role="presentation" style="<?php echo esc_attr( $table_style ); ?>"> <tbody> <tr> <td> <?php for ( $i = 0; $i < $total_stars; $i++ ) : $is_filled = $i < floor( $active_stars ); $color = $is_filled ? $active_color : $inactive_color; $cell_styles = [ 'color' => $color, 'font-size' => $size . 'px', 'line-height' => 1, 'padding' => '0', 'padding-left' => ( $spacing / 2 ) . 'px', 'padding-right' => ( $spacing / 2 ) . 'px', 'display' => 'inline-block', ]; ?> <span style="<?php echo esc_attr( TemplateHelpers::get_style( $cell_styles ) ); ?>">★</span> <?php endfor; ?> </td> </tr> </tbody> </table> <?php
$element_content = ob_get_clean();
TemplateHelpers::wrap_element_content( $element_content, $element, $wrapper_style );
|