| 1 |
<?php |
| 2 |
/** |
| 3 |
* Dashboard counters widget. |
| 4 |
* |
| 5 |
* @package Formidable |
| 6 |
* |
| 7 |
* @var array $template Widget data with a 'counters' array. Each counter has: heading, type, counter, cta and optional items. |
| 8 |
*/ |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
die( 'You are not allowed to call this page directly.' ); |
| 12 |
} |
| 13 |
|
| 14 |
$classname = 'frm-counter-card-wrapper frm-flex-box'; |
| 15 |
?> |
| 16 |
|
| 17 |
<?php if ( ! empty( $template ) && isset( $template['counters'] ) && is_array( $template['counters'] ) ) : ?> |
| 18 |
<div class="<?php echo esc_attr( $classname ); ?>"> |
| 19 |
|
| 20 |
<?php foreach ( $template['counters'] as $counter ) : ?> |
| 21 |
<div class="frm-counter-card frm-dashboard-widget frm-card-item"> |
| 22 |
<h4><?php echo esc_html( $counter['heading'] ); ?></h4> |
| 23 |
<?php if ( isset( $counter['cta'] ) && isset( $counter['cta']['display'] ) && true === $counter['cta']['display'] ) : ?> |
| 24 |
<a href="<?php echo esc_url( $counter['cta']['link'] ); ?>"><?php echo esc_html( $counter['cta']['title'] ); ?></a> |
| 25 |
<?php else : ?> |
| 26 |
<?php if ( 'currency' === $counter['type'] ) : ?> |
| 27 |
<div class="frm-flex-box frm-gap-md"> |
| 28 |
<?php foreach ( $counter['items'] as $item ) : ?> |
| 29 |
<b> |
| 30 |
<?php echo esc_html( $item['counter_label']['symbol_left'] ); ?> |
| 31 |
<span class="frm-counter" data-type="<?php echo esc_attr( $counter['type'] ); ?>" data-locale="<?php echo esc_attr( get_locale() ); ?>" data-counter="<?php echo (int) $item['counter']; ?>"><?php echo (int) $item['counter']; ?></span> |
| 32 |
<?php echo esc_html( $item['counter_label']['symbol_right'] ); ?> |
| 33 |
</b> |
| 34 |
<?php endforeach; ?> |
| 35 |
</div> |
| 36 |
<?php else : ?> |
| 37 |
<b> |
| 38 |
<span class="frm-counter" data-type="<?php echo esc_attr( $counter['type'] ); ?>" data-locale="<?php echo esc_attr( get_locale() ); ?>" data-counter="<?php echo (int) $counter['counter']; ?>"><?php echo (int) $counter['counter']; ?></span> |
| 39 |
</b> |
| 40 |
<?php endif; ?> |
| 41 |
<?php endif; ?> |
| 42 |
</div> |
| 43 |
<?php endforeach; ?> |
| 44 |
</div> |
| 45 |
<?php endif; ?> |
| 46 |
|