qna
5 days ago
reviews
5 days ago
announcements.php
5 days ago
course-info.php
5 days ago
qna.php
5 days ago
reviews.php
5 days ago
announcements.php
97 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Tutor learning area announcements. |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @author Themeum <support@themeum.com> |
| 7 | * @link https://themeum.com |
| 8 | * @since 4.0.0 |
| 9 | */ |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | use TUTOR\Announcements; |
| 14 | use Tutor\Components\Avatar; |
| 15 | use Tutor\Components\Constants\Size; |
| 16 | use TUTOR\Icon; |
| 17 | use Tutor\Components\SvgIcon; |
| 18 | use TUTOR\Input; |
| 19 | use Tutor\Components\EmptyState; |
| 20 | use Tutor\Components\Pagination; |
| 21 | |
| 22 | // Get course ID from global variable set in learning-area/index.php . |
| 23 | global $tutor_course_id; |
| 24 | |
| 25 | // Pagination setup. |
| 26 | $limit = (int) tutor_utils()->get_option( 'pagination_per_page', 10 ); |
| 27 | $current_page = max( 1, Input::get( 'current_page', 1, Input::TYPE_INT ) ); |
| 28 | |
| 29 | $args = array( |
| 30 | 'posts_per_page' => $limit, |
| 31 | 'paged' => $current_page, |
| 32 | 'orderBy' => 'ID', |
| 33 | 'order' => 'DESC', |
| 34 | 'post_parent' => $tutor_course_id, |
| 35 | ); |
| 36 | |
| 37 | $the_query = Announcements::get_announcements( $args ); |
| 38 | $announcements = $the_query->have_posts() ? $the_query->posts : array(); |
| 39 | $total_announcements = $the_query->found_posts; |
| 40 | |
| 41 | ?> |
| 42 | <div class="tutor-py-8"> |
| 43 | <h4 class="tutor-h4 tutor-mb-5 tutor-flex tutor-items-center tutor-gap-4"> |
| 44 | <?php SvgIcon::make()->name( Icon::ANNOUNCEMENT )->size( 24 )->render(); ?> |
| 45 | <?php esc_html_e( 'Announcements', 'tutor' ); ?> |
| 46 | </h4> |
| 47 | <div class="tutor-course-announcements"> |
| 48 | <?php if ( empty( $announcements ) ) : ?> |
| 49 | <?php |
| 50 | EmptyState::make() |
| 51 | ->title( __( 'No Announcements Found!', 'tutor' ) ) |
| 52 | ->icon( tutor_utils()->get_themed_svg( 'images/illustrations/no-announcements.svg' ) ) |
| 53 | ->render(); |
| 54 | ?> |
| 55 | <?php else : ?> |
| 56 | <div class="tutor-announcement-list"> |
| 57 | <?php foreach ( $announcements as $announcement ) : ?> |
| 58 | <div class="tutor-announcement-item"> |
| 59 | <div class="tutor-medium tutor-font-medium tutor-mb-4"> |
| 60 | <?php echo esc_html( $announcement->post_title ); ?> |
| 61 | </div> |
| 62 | <div class="tutor-p2 tutor-mb-7 tutor-whitespace-pre-line"> |
| 63 | <?php echo wp_kses_post( $announcement->post_content ); ?> |
| 64 | </div> |
| 65 | <div class="tutor-flex tutor-items-center tutor-justify-between tutor-gap-3"> |
| 66 | <div class="tutor-flex tutor-items-center tutor-gap-3"> |
| 67 | <?php |
| 68 | $author_id = (int) $announcement->post_author; |
| 69 | $author_name = tutor_utils()->display_name( $author_id ); |
| 70 | ?> |
| 71 | <?php Avatar::make()->user( $author_id )->size( Size::SIZE_24 )->render(); ?> |
| 72 | <div class="tutor-small tutor-flex tutor-items-center tutor-gap-2"> |
| 73 | <span class="tutor-text-subdued"><?php esc_html_e( 'By:', 'tutor' ); ?></span> |
| 74 | <span class="tutor-author-name tutor-line-clamp-1"><?php echo esc_html( $author_name ); ?></span> |
| 75 | </div> |
| 76 | </div> |
| 77 | <div class="tutor-tiny tutor-text-secondary tutor-flex tutor-items-center tutor-gap-3 tutor-flex-shrink-0"> |
| 78 | <?php SvgIcon::make()->name( Icon::ANNOUNCEMENT )->render(); ?> |
| 79 | <?php echo esc_html( tutor_i18n_get_formated_date( $announcement->post_date ) ); ?> |
| 80 | </div> |
| 81 | </div> |
| 82 | </div> |
| 83 | <?php endforeach; ?> |
| 84 | </div> |
| 85 | <?php endif; ?> |
| 86 | |
| 87 | <?php |
| 88 | Pagination::make() |
| 89 | ->current( $current_page ) |
| 90 | ->total( $total_announcements ) |
| 91 | ->limit( $limit ) |
| 92 | ->attr( 'class', 'tutor-px-6 tutor-pb-6 tutor-sm-p-5 tutor-sm-border-t' ) |
| 93 | ->render(); |
| 94 | ?> |
| 95 | </div> |
| 96 | </div> |
| 97 |