sidebar-nav-item.php
48 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Render a single nav item for learning area sidebar. |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage LearningArea |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 4.0.2 |
| 10 | */ |
| 11 | |
| 12 | defined( 'ABSPATH' ) || exit; |
| 13 | |
| 14 | use Tutor\Components\SvgIcon; |
| 15 | |
| 16 | $item = $item ?? null; |
| 17 | $active = $active ?? false; |
| 18 | $can_access = $can_access ?? false; |
| 19 | $is_completed = $is_completed ?? false; |
| 20 | $type_label = $type_label ?? ''; |
| 21 | $icon = $icon ?? ''; |
| 22 | $status_class = $status_class ?? ''; |
| 23 | |
| 24 | if ( ! $item || ! is_a( $item, 'WP_Post' ) ) { |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | $active_class = $active ? 'active' : ''; |
| 29 | $item_title = $item->post_title; |
| 30 | $allowed_html = array( |
| 31 | 'span' => array( |
| 32 | 'class' => array(), |
| 33 | ), |
| 34 | ); |
| 35 | ?> |
| 36 | |
| 37 | <a |
| 38 | href="<?php echo esc_url( get_permalink( $item->ID ) ); ?>" |
| 39 | title="<?php echo esc_attr( $item_title ); ?>" |
| 40 | class="<?php echo esc_attr( sprintf( 'tutor-learning-nav-item %s %s', $active_class, $status_class ) ); ?>" |
| 41 | > |
| 42 | <?php SvgIcon::make()->name( $icon )->size( 20 )->render(); ?> |
| 43 | <div class="tutor-overflow-hidden"> |
| 44 | <div><?php echo esc_html( $item_title ); ?></div> |
| 45 | <div class="tutor-tiny-2 tutor-text-subdued"><?php echo wp_kses( $type_label, $allowed_html ); ?></div> |
| 46 | </div> |
| 47 | </a> |
| 48 |