announcements
1 year ago
assignments
8 months ago
elements
1 year ago
enrolled-courses
3 years ago
instructor
2 years ago
my-courses
1 year ago
my-quiz-attempts
3 years ago
notifications
3 years ago
question-answer
1 year ago
quiz-attempts
3 years ago
reviews
3 years ago
settings
1 year ago
withdraw-method-fields
3 years ago
announcements.php
1 year ago
assignments.php
11 months ago
create-course.php
1 year ago
dashboard.php
8 months ago
enrolled-courses.php
8 months ago
index.php
3 years ago
logged-in.php
3 years ago
my-courses.php
8 months ago
my-profile.php
9 months ago
my-quiz-attempts.php
3 years ago
purchase_history.php
10 months ago
question-answer.php
11 months ago
quiz-attempts.php
1 year ago
registration.php
2 years ago
reviews.php
3 years ago
settings.php
1 year ago
wishlist.php
1 year ago
withdraw.php
1 year ago
announcements.php
139 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for displaying Announcements |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Dashboard |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 1.7.9 |
| 10 | */ |
| 11 | |
| 12 | use TUTOR\Input; |
| 13 | use Tutor\Models\CourseModel; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | $per_page = tutor_utils()->get_option( 'pagination_per_page', 10 ); |
| 20 | $paged = max( 1, Input::get( 'current_page', 1, Input::TYPE_INT ) ); |
| 21 | |
| 22 | $order_filter = Input::get( 'order', 'DESC' ); |
| 23 | $search_filter = Input::get( 'search', '' ); |
| 24 | |
| 25 | // Announcement's parent. |
| 26 | $course_id = Input::get( 'course-id', '' ); |
| 27 | $date_filter = Input::get( 'date', '' ); |
| 28 | |
| 29 | $year = date( 'Y', strtotime( $date_filter ) ); |
| 30 | $month = date( 'm', strtotime( $date_filter ) ); |
| 31 | $day = date( 'd', strtotime( $date_filter ) ); |
| 32 | |
| 33 | $args = array( |
| 34 | 'post_type' => 'tutor_announcements', |
| 35 | 'post_status' => 'publish', |
| 36 | 's' => sanitize_text_field( $search_filter ), |
| 37 | 'post_parent' => sanitize_text_field( $course_id ), |
| 38 | 'posts_per_page' => sanitize_text_field( $per_page ), |
| 39 | 'paged' => sanitize_text_field( $paged ), |
| 40 | 'orderBy' => 'ID', |
| 41 | 'order' => sanitize_text_field( $order_filter ), |
| 42 | |
| 43 | ); |
| 44 | if ( ! empty( $date_filter ) ) { |
| 45 | $args['date_query'] = array( |
| 46 | array( |
| 47 | 'year' => $year, |
| 48 | 'month' => $month, |
| 49 | 'day' => $day, |
| 50 | ), |
| 51 | ); |
| 52 | } |
| 53 | if ( ! current_user_can( 'administrator' ) ) { |
| 54 | $args['author'] = get_current_user_id(); |
| 55 | } |
| 56 | $the_query = new WP_Query( $args ); |
| 57 | |
| 58 | // Get courses. |
| 59 | $courses = ( current_user_can( 'administrator' ) ) ? CourseModel::get_courses() : CourseModel::get_courses_by_instructor(); |
| 60 | $image_base = tutor()->url . '/assets/images/'; |
| 61 | ?> |
| 62 | |
| 63 | <div class="tutor-card tutor-p-24"> |
| 64 | <div class="tutor-row tutor-align-lg-center"> |
| 65 | <div class="tutor-col-lg-auto tutor-mb-16 tutor-mb-lg-0"> |
| 66 | <div class="tutor-round-box tutor-p-8"> |
| 67 | <i class="tutor-icon-bullhorn tutor-fs-3" area-hidden="true"></i> |
| 68 | </div> |
| 69 | </div> |
| 70 | |
| 71 | <div class="tutor-col tutor-mb-16 tutor-mb-lg-0"> |
| 72 | <div class="tutor-fs-6 tutor-color-muted tutor-mb-4"> |
| 73 | <?php esc_html_e( 'Create Announcement', 'tutor' ); ?> |
| 74 | </div> |
| 75 | <div class="tutor-fs-5 tutor-color-black"> |
| 76 | <?php esc_html_e( 'Notify all students of your course', 'tutor' ); ?> |
| 77 | </div> |
| 78 | </div> |
| 79 | |
| 80 | <div class="tutor-col-lg-auto"> |
| 81 | <button type="button" class="tutor-btn tutor-btn-primary" data-tutor-modal-target="tutor_announcement_new"> |
| 82 | <?php esc_html_e( 'Add New Announcement', 'tutor' ); ?> |
| 83 | </button> |
| 84 | </div> |
| 85 | </div> |
| 86 | </div> |
| 87 | |
| 88 | <div class="tutor-row tutor-mb-32 tutor-mt-44" style="width: calc(100% + 30px);"> |
| 89 | <div class="tutor-col-12 tutor-col-lg-6 tutor-mt-12 tutor-mt-lg-0"> |
| 90 | <label class="tutor-d-block tutor-mb-12 tutor-form-label"> |
| 91 | <?php esc_html_e( 'Courses', 'tutor' ); ?> |
| 92 | </label> |
| 93 | <select class="tutor-form-select tutor-announcement-course-sorting" data-searchable> |
| 94 | <option value=""><?php esc_html_e( 'All', 'tutor' ); ?></option> |
| 95 | <?php if ( $courses ) : ?> |
| 96 | <?php foreach ( $courses as $course ) : ?> |
| 97 | <option value="<?php echo esc_attr( $course->ID ); ?>" <?php selected( $course_id, $course->ID, 'selected' ); ?>> |
| 98 | <?php echo esc_html( $course->post_title ); ?> |
| 99 | </option> |
| 100 | <?php endforeach; ?> |
| 101 | <?php else : ?> |
| 102 | <option value=""><?php esc_html_e( 'No course found', 'tutor' ); ?></option> |
| 103 | <?php endif; ?> |
| 104 | </select> |
| 105 | </div> |
| 106 | |
| 107 | <div class="tutor-col-6 tutor-col-lg-3 tutor-mt-12 tutor-mt-lg-0"> |
| 108 | <label class="tutor-d-block tutor-mb-12 tutor-form-label"><?php esc_html_e( 'Sort By', 'tutor' ); ?></label> |
| 109 | <select class="tutor-form-select tutor-announcement-order-sorting tutor-form-control-sm" data-search="no"> |
| 110 | <option <?php selected( $order_filter, 'ASC' ); ?>><?php esc_html_e( 'ASC', 'tutor' ); ?></option> |
| 111 | <option <?php selected( $order_filter, 'DESC' ); ?>><?php esc_html_e( 'DESC', 'tutor' ); ?></option> |
| 112 | </select> |
| 113 | </div> |
| 114 | |
| 115 | <div class="tutor-col-6 tutor-col-lg-3 tutor-mt-12 tutor-mt-lg-0"> |
| 116 | <label class="tutor-form-label tutor-d-block tutor-mb-12"><?php esc_html_e( 'Date', 'tutor' ); ?></label> |
| 117 | <div class="tutor-v2-date-picker"> |
| 118 | <div class="tutor-form-wrap"> |
| 119 | <span class="tutor-form-icon tutor-form-icon-reverse"> |
| 120 | <span class="tutor-icon-calender-line" aria-hidden="true"></span> |
| 121 | </span> |
| 122 | <input class="tutor-form-control" placeholder="<?php esc_attr_e( 'Loading...', 'tutor' ); ?>"> |
| 123 | </div> |
| 124 | </div> |
| 125 | </div> |
| 126 | </div> |
| 127 | |
| 128 | <?php |
| 129 | $announcements = $the_query->have_posts() ? $the_query->posts : array(); |
| 130 | tutor_load_template_from_custom_path( |
| 131 | tutor()->path . '/views/fragments/announcement-list.php', |
| 132 | array( |
| 133 | 'announcements' => is_array( $announcements ) ? $announcements : array(), |
| 134 | 'the_query' => $the_query, |
| 135 | 'paged' => $paged, |
| 136 | ) |
| 137 | ); |
| 138 | ?> |
| 139 |