continue-learning.php
1 day ago
dashboard-empty.php
1 day ago
dashboard.php
1 day ago
stat-card.php
1 day ago
stats.php
1 day ago
time-spent-modal.php
1 day ago
stat-card.php
48 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Single Stat Card Reusable Component |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Dashboard |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 4.0.0 |
| 10 | */ |
| 11 | |
| 12 | defined( 'ABSPATH' ) || exit; |
| 13 | |
| 14 | use Tutor\Components\SvgIcon; |
| 15 | |
| 16 | $tag = isset( $url ) && ! empty( $url ) ? 'a' : 'div'; |
| 17 | $class_name = $class ?? ''; |
| 18 | $icon_size = $icon_size ?? 20; |
| 19 | $modal_id = isset( $modal_id ) ? sanitize_key( $modal_id ) : ''; |
| 20 | $modal_action = $modal_id ? sprintf( "TutorCore.modal.showModal('%s')", $modal_id ) : ''; |
| 21 | $card_attributes = ''; |
| 22 | |
| 23 | if ( 'a' === $tag ) { |
| 24 | $card_attributes = sprintf( ' href="%s"', esc_url( $url ) ); |
| 25 | } elseif ( $modal_action ) { |
| 26 | $card_attributes = sprintf( |
| 27 | ' role="button" tabindex="0" @click="%1$s" @keydown.enter.prevent="%1$s" @keydown.space.prevent="%1$s"', |
| 28 | esc_attr( $modal_action ) |
| 29 | ); |
| 30 | } |
| 31 | ?> |
| 32 | |
| 33 | <<?php echo tag_escape( $tag ); ?><?php echo $card_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Attribute values are escaped above. ?> class="tutor-stat-card <?php echo esc_attr( $class_name ); ?>"> |
| 34 | <div class="tutor-stat-card-header"> |
| 35 | <h3 class="tutor-stat-card-title"> |
| 36 | <?php echo esc_html( $title ); ?> |
| 37 | </h3> |
| 38 | <div class="tutor-stat-card-icon tutor-flex"> |
| 39 | <?php SvgIcon::make()->name( $icon )->size( $icon_size )->render(); ?> |
| 40 | </div> |
| 41 | </div> |
| 42 | <div class="tutor-stat-card-content"> |
| 43 | <div class="tutor-stat-card-value"> |
| 44 | <?php echo esc_html( $value ); ?> |
| 45 | </div> |
| 46 | </div> |
| 47 | </<?php echo tag_escape( $tag ); ?>> |
| 48 |