tools
5 years ago
add_new_instructor.php
4 years ago
addons.php
5 years ago
announcements.php
4 years ago
answer.php
4 years ago
enable_disable_addons.php
4 years ago
get-pro.php
5 years ago
instructors.php
4 years ago
question_answer.php
4 years ago
quiz_attempts.php
4 years ago
students.php
4 years ago
tools.php
5 years ago
tutor-pro-addons.php
5 years ago
uninstall.php
4 years ago
view_attempt.php
4 years ago
withdraw_requests.php
4 years ago
announcements.php
336 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) |
| 3 | exit; |
| 4 | |
| 5 | /** |
| 6 | * Since 1.7.9 |
| 7 | * configure query with get params |
| 8 | */ |
| 9 | $per_page = 10; |
| 10 | $paged = (isset($_GET['paged']) && is_numeric($_GET['paged']) && $_GET['paged']>=1) ? $_GET['paged'] : 1; |
| 11 | |
| 12 | $order_filter = (isset($_GET['order']) && strtolower($_GET['order'])=='asc') ? 'ASC' : 'DESC'; |
| 13 | $search_filter = sanitize_text_field( tutor_utils()->array_get('search', $_GET, '') ); |
| 14 | //announcement's parent |
| 15 | $course_id = sanitize_text_field( tutor_utils()->array_get('course-id', $_GET, '') ); |
| 16 | $date_filter = sanitize_text_field( tutor_utils()->array_get('date', $_GET, '') ); |
| 17 | |
| 18 | $year = date('Y', strtotime($date_filter)); |
| 19 | $month = date('m', strtotime($date_filter)); |
| 20 | $day = date('d', strtotime($date_filter)); |
| 21 | |
| 22 | $args = array( |
| 23 | 'post_type' => 'tutor_announcements', |
| 24 | 'post_status' => 'publish', |
| 25 | 's' => $search_filter, |
| 26 | 'post_parent' => $course_id, |
| 27 | 'posts_per_page' => sanitize_text_field($per_page), |
| 28 | 'paged' => sanitize_text_field($paged), |
| 29 | 'orderBy' => 'ID', |
| 30 | 'order' => sanitize_text_field($order_filter), |
| 31 | |
| 32 | ); |
| 33 | if (!empty($date_filter)) { |
| 34 | $args['date_query'] = array( |
| 35 | array( |
| 36 | 'year' => $year, |
| 37 | 'month' => $month, |
| 38 | 'day' => $day |
| 39 | ) |
| 40 | ); |
| 41 | } |
| 42 | if (!current_user_can('administrator')) { |
| 43 | $args['author'] = get_current_user_id(); |
| 44 | } |
| 45 | $the_query = new WP_Query($args); |
| 46 | ?> |
| 47 | |
| 48 | <div class="tutor-admin-search-box-container"> |
| 49 | |
| 50 | <div> |
| 51 | <div class="menu-label"><?php _e('Search', 'tutor'); ?></div> |
| 52 | <div> |
| 53 | <input type="text" class="tutor-report-search tutor-announcement-search-field" value="<?php echo $search_filter; ?>" autocomplete="off" placeholder="<?php _e('Search Announcements', 'tutor'); ?>" /> |
| 54 | <button class="tutor-report-search-btn tutor-announcement-search-sorting"><i class="tutor-icon-magnifying-glass-1"></i></button> |
| 55 | </div> |
| 56 | </div> |
| 57 | |
| 58 | <div> |
| 59 | <div class="menu-label"><?php _e('Courses', 'tutor'); ?></div> |
| 60 | <div> |
| 61 | <?php |
| 62 | //get courses |
| 63 | $courses = (current_user_can('administrator')) ? tutils()->get_courses() : tutils()->get_courses_by_instructor(); |
| 64 | ?> |
| 65 | |
| 66 | <select class="tutor-report-category tutor-announcement-course-sorting"> |
| 67 | |
| 68 | <option value=""><?php _e('All', 'tutor'); ?></option> |
| 69 | |
| 70 | <?php if ($courses) : ?> |
| 71 | <?php foreach ($courses as $course) : ?> |
| 72 | <option value="<?php echo esc_attr($course->ID) ?>" <?php selected($course_id, $course->ID, 'selected') ?>> |
| 73 | <?php echo $course->post_title; ?> |
| 74 | </option> |
| 75 | <?php endforeach; ?> |
| 76 | <?php else : ?> |
| 77 | <option value=""><?php _e('No course found', 'tutor'); ?></option> |
| 78 | <?php endif; ?> |
| 79 | </select> |
| 80 | </div> |
| 81 | </div> |
| 82 | |
| 83 | <div> |
| 84 | <div class="menu-label"><?php _e('Sort By', 'tutor'); ?></div> |
| 85 | <div> |
| 86 | <select class="tutor-report-sort tutor-announcement-order-sorting"> |
| 87 | <option <?php selected($order_filter, 'ASC'); ?>>ASC</option> |
| 88 | <option <?php selected($order_filter, 'DESC'); ?>>DESC</option> |
| 89 | </select> |
| 90 | </div> |
| 91 | </div> |
| 92 | |
| 93 | <div> |
| 94 | <div class="menu-label"><?php _e('Date', 'tutor'); ?></div> |
| 95 | <div class="date-range-input"> |
| 96 | <input type="text" class="tutor_date_picker tutor-announcement-date-sorting" id="tutor-announcement-datepicker" placeholder="<?php _e( get_option( 'date_format' ), 'tutor' );?>" value="<?php echo '' !== $date_filter ? tutor_get_formated_date( get_option( 'date_format' ), $date_filter ) : ''; ?>" autocomplete="off" /> |
| 97 | <i class="tutor-icon-calendar"></i> |
| 98 | </div> |
| 99 | </div> |
| 100 | </div> |
| 101 | |
| 102 | <div class="tutor-list-wrap tutor-report-course-list"> |
| 103 | <div class="tutor-list-header tutor-announcements-header"> |
| 104 | <div class="heading"><?php _e('Announcements', 'tutor'); ?></div> |
| 105 | <button type="button" class="tutor-btn bordered-btn tutor-announcement-add-new"> |
| 106 | <?php _e('Add new', 'tutor'); ?> |
| 107 | </button> |
| 108 | </div> |
| 109 | |
| 110 | <table class="tutor-list-table tutor-announcement-table"> |
| 111 | <thead> |
| 112 | <tr> |
| 113 | <th style="width:20%"><?php _e('Date', 'tutor'); ?></th> |
| 114 | <th><?php _e('Announcements', 'tutor'); ?></th> |
| 115 | </tr> |
| 116 | </thead> |
| 117 | <tbody> |
| 118 | <?php if ($the_query->have_posts()) : ?> |
| 119 | <?php foreach ($the_query->posts as $post) : ?> |
| 120 | <?php |
| 121 | $course = get_post($post->post_parent); |
| 122 | $dateObj = date_create($post->post_date); |
| 123 | $date_format = date_format($dateObj, 'F j, Y, g:i a'); |
| 124 | ?> |
| 125 | <tr id="tutor-announcement-tr-<?php echo $post->ID; ?>"> |
| 126 | <td class="tutor-announcement-date"><?php echo esc_html($date_format); ?></td> |
| 127 | <td class="tutor-announcement-content-wrap"> |
| 128 | <div class="tutor-announcement-content"> |
| 129 | <span> |
| 130 | <?php echo esc_html($post->post_title); ?> |
| 131 | </span> |
| 132 | <p> |
| 133 | <?php echo $course ? $course->post_title : ''; ?> |
| 134 | </p> |
| 135 | </div> |
| 136 | <div class="tutor-announcement-buttons"> |
| 137 | |
| 138 | <button type="button" announcement-title="<?php echo esc_attr($post->post_title); ?>" announcement-summary="<?php echo esc_attr( $post->post_content ); ?>" course-id="<?php echo $post->post_parent; ?>" announcement-id="<?php echo $post->ID; ?>" class="tutor-btn bordered-btn tutor-announcement-edit"> |
| 139 | <?php _e('Edit', 'tutor'); ?> |
| 140 | </button> |
| 141 | <button type="button" class="tutor-btn bordered-btn tutor-announcement-delete" announcement-id="<?php echo $post->ID; ?>"> |
| 142 | <?php _e('Delete', 'tutor'); ?> |
| 143 | </button> |
| 144 | |
| 145 | </div> |
| 146 | </td> |
| 147 | </tr> |
| 148 | <?php endforeach; ?> |
| 149 | <?php else : ?> |
| 150 | <tr> |
| 151 | <td colspan="2"> |
| 152 | <?php _e('Announcements not found', 'tutor'); ?> |
| 153 | </td> |
| 154 | </tr> |
| 155 | <?php endif; ?> |
| 156 | </tbody> |
| 157 | </table> |
| 158 | |
| 159 | </div> |
| 160 | |
| 161 | <!--pagination--> |
| 162 | <div class="tutor-announcement-pagination"> |
| 163 | <?php |
| 164 | $big = 999999999; // need an unlikely integer |
| 165 | |
| 166 | echo paginate_links(array( |
| 167 | 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
| 168 | 'format' => '?current_page=%#%', |
| 169 | 'current' => $paged, |
| 170 | 'total' => $the_query->max_num_pages |
| 171 | )); |
| 172 | ?> |
| 173 | </div> |
| 174 | <!--pagination end--> |
| 175 | |
| 176 | <!--create announcements modal--> |
| 177 | <div class="tutor-modal-wrap tutor-announcements-modal-wrap tutor-announcement-create-modal" id="tutor-annoucement-backend-create-modal"> |
| 178 | <div class="tutor-modal-content"> |
| 179 | <div class="modal-header"> |
| 180 | <div class="modal-title"> |
| 181 | <h1><?php _e('Create New Announcement', 'tutor'); ?></h1> |
| 182 | </div> |
| 183 | <div class="tutor-announcements-modal-close-wrap"> |
| 184 | <a href="#" class="tutor-announcement-close-btn"> |
| 185 | <i class="tutor-icon-line-cross"></i> |
| 186 | </a> |
| 187 | </div> |
| 188 | </div> |
| 189 | <div class="modal-container"> |
| 190 | <form action="" class="tutor-announcements-form"> |
| 191 | <?php tutor_nonce_field(); ?> |
| 192 | <div class="tutor-option-field-row"> |
| 193 | <label for="tutor_announcement_course"> |
| 194 | <?php _e('Select Course', 'tutor'); ?> |
| 195 | </label> |
| 196 | |
| 197 | <div class="tutor-announcement-form-control"> |
| 198 | <select name="tutor_announcement_course" id="" required> |
| 199 | <?php if ($courses) : ?> |
| 200 | <?php foreach ($courses as $course) : ?> |
| 201 | |
| 202 | <option value="<?php echo esc_attr($course->ID) ?>"> |
| 203 | <?php echo $course->post_title; ?> |
| 204 | </option> |
| 205 | <?php endforeach; ?> |
| 206 | <?php else : ?> |
| 207 | <option value="">No course found</option> |
| 208 | <?php endif; ?> |
| 209 | </select> |
| 210 | |
| 211 | </div> |
| 212 | </div> |
| 213 | |
| 214 | <div class="tutor-option-field-row"> |
| 215 | <label for="tutor_announcement_course"> |
| 216 | <?php _e('Announcement Title', 'tutor'); ?> |
| 217 | </label> |
| 218 | |
| 219 | <div class="tutor-announcement-form-control"> |
| 220 | <input type="text" name="tutor_announcement_title" value="" placeholder="<?php _e('Announcement title', 'tutor'); ?>" required> |
| 221 | </div> |
| 222 | </div> |
| 223 | |
| 224 | <div class="tutor-option-field-row"> |
| 225 | <label for="tutor_announcement_course"> |
| 226 | <?php _e('Summary', 'tutor'); ?> |
| 227 | </label> |
| 228 | |
| 229 | <div class="tutor-announcement-form-control"> |
| 230 | <textarea rows="6" type="text" name="tutor_announcement_summary" value="" placeholder="<?php _e('Summary...', 'tutor'); ?>" required></textarea> |
| 231 | </div> |
| 232 | </div> |
| 233 | |
| 234 | <?php do_action('tutor_announcement_editor/after'); ?> |
| 235 | |
| 236 | <div class="tutor-option-field-row"> |
| 237 | <div class="tutor-announcements-create-alert"></div> |
| 238 | </div> |
| 239 | |
| 240 | <div class="modal-footer"> |
| 241 | <div class="tutor-quiz-builder-modal-control-btn-group"> |
| 242 | <div class="quiz-builder-btn-group-left"> |
| 243 | <button type="submit" class="tutor-btn"><?php _e('Publish', 'tutor') ?></button> |
| 244 | </div> |
| 245 | <div class="quiz-builder-btn-group-right"> |
| 246 | <button type="button" class="quiz-modal-tab-navigation-btn quiz-modal-btn-cancel tutor-announcement-close-btn"><?php _e('Cancel', 'tutor') ?></button> |
| 247 | </div> |
| 248 | </div> |
| 249 | </div> |
| 250 | </form> |
| 251 | </div> |
| 252 | </div> |
| 253 | </div> |
| 254 | <!--create announcements modal end--> |
| 255 | |
| 256 | <!--update announcements modal--> |
| 257 | <div class="tutor-modal-wrap tutor-announcements-modal-wrap tutor-accouncement-update-modal"> |
| 258 | <div class="tutor-modal-content"> |
| 259 | <div class="modal-header"> |
| 260 | <div class="modal-title"> |
| 261 | <h1><?php _e('Update Announcement', 'tutor'); ?></h1> |
| 262 | </div> |
| 263 | <div class="tutor-announcements-modal-close-wrap"> |
| 264 | <a href="#" class="tutor-announcement-close-btn"> |
| 265 | <i class="tutor-icon-line-cross"></i> |
| 266 | </a> |
| 267 | </div> |
| 268 | </div> |
| 269 | |
| 270 | <div class="modal-container"> |
| 271 | <form action="" class="tutor-announcements-update-form"> |
| 272 | <?php tutor_nonce_field(); ?> |
| 273 | <input type="hidden" name="announcement_id" id="announcement_id"> |
| 274 | <div class="tutor-option-field-row"> |
| 275 | <label for="tutor_announcement_course"> |
| 276 | <?php _e('Select Course', 'tutor'); ?> |
| 277 | </label> |
| 278 | |
| 279 | <div class="tutor-announcement-form-control"> |
| 280 | <select name="tutor_announcement_course" id="tutor-announcement-course-id" required> |
| 281 | <?php if ($courses) : ?> |
| 282 | <?php foreach ($courses as $course) : ?> |
| 283 | |
| 284 | <option value="<?php echo esc_attr($course->ID) ?>"> |
| 285 | <?php echo $course->post_title; ?> |
| 286 | </option> |
| 287 | <?php endforeach; ?> |
| 288 | <?php else : ?> |
| 289 | <option value="">No course found</option> |
| 290 | <?php endif; ?> |
| 291 | </select> |
| 292 | |
| 293 | </div> |
| 294 | </div> |
| 295 | |
| 296 | <div class="tutor-option-field-row"> |
| 297 | <label for="tutor_announcement_course"> |
| 298 | <?php _e('Announcement Title', 'tutor'); ?> |
| 299 | </label> |
| 300 | |
| 301 | <div class="tutor-announcement-form-control"> |
| 302 | <input type="text" name="tutor_announcement_title" id="tutor-announcement-title" value="" placeholder="<?php _e('Announcement title', 'tutor'); ?>" required> |
| 303 | </div> |
| 304 | </div> |
| 305 | |
| 306 | <div class="tutor-option-field-row"> |
| 307 | <label for="tutor_announcement_course"> |
| 308 | <?php _e('Summary', 'tutor'); ?> |
| 309 | </label> |
| 310 | |
| 311 | <div class="tutor-announcement-form-control"> |
| 312 | <textarea rows="6" type="text" id="tutor-announcement-summary" name="tutor_announcement_summary" value="" placeholder="<?php _e('Summary...', 'tutor'); ?>" required></textarea> |
| 313 | </div> |
| 314 | </div> |
| 315 | |
| 316 | <?php do_action('tutor_announcement_editor/after'); ?> |
| 317 | |
| 318 | <div class="tutor-option-field-row"> |
| 319 | <div class="tutor-announcements-update-alert"></div> |
| 320 | </div> |
| 321 | |
| 322 | <div class="modal-footer"> |
| 323 | <div class="tutor-quiz-builder-modal-control-btn-group"> |
| 324 | <div class="quiz-builder-btn-group-left"> |
| 325 | <button type="submit" class="tutor-btn"><?php _e('Update', 'tutor') ?></button> |
| 326 | </div> |
| 327 | <div class="quiz-builder-btn-group-right"> |
| 328 | <button type="button" class="quiz-modal-tab-navigation-btn quiz-modal-btn-cancel tutor-announcement-close-btn"><?php _e('Cancel', 'tutor') ?></button> |
| 329 | </div> |
| 330 | </div> |
| 331 | </div> |
| 332 | </form> |
| 333 | </div> |
| 334 | </div> |
| 335 | </div> |
| 336 | <!--update announcements modal end--> |