given-reviews.php
161 lines
| 1 | <?php |
| 2 | /** |
| 3 | * My Own reviews |
| 4 | * |
| 5 | * @since v.1.1.2 |
| 6 | * |
| 7 | * @author Themeum |
| 8 | * @url https://themeum.com |
| 9 | * |
| 10 | * @package TutorLMS/Templates |
| 11 | * @version 1.4.3 |
| 12 | * |
| 13 | * To be loaded for given review list in frontend dashboard |
| 14 | */ |
| 15 | |
| 16 | // Pagination Variable |
| 17 | $per_page = tutor_utils()->get_option( 'pagination_per_page', 20 ); |
| 18 | $current_page = max( 1, tutor_utils()->avalue_dot( 'current_page', $_GET ) ); |
| 19 | $offset = ( $current_page - 1 ) * $per_page; |
| 20 | |
| 21 | |
| 22 | $all_reviews = tutor_utils()->get_reviews_by_user( 0, $offset, $per_page, true ); |
| 23 | $review_count = $all_reviews->count; |
| 24 | $reviews = $all_reviews->results; |
| 25 | $received_count = tutor_utils()->get_reviews_by_instructor( 0, 0, 0 )->count; |
| 26 | ?> |
| 27 | |
| 28 | <div class="tutor-dashboard-content-inner"> |
| 29 | <div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-24"><?php _e( 'Reviews', 'tutor' ); ?></div> |
| 30 | <?php if ( current_user_can( tutor()->instructor_role ) ) : ?> |
| 31 | <div class="tutor-mb-32"> |
| 32 | <ul class="tutor-nav"> |
| 33 | <li class="tutor-nav-item"> |
| 34 | <a class="tutor-nav-link" href="<?php echo esc_url( tutor_utils()->get_tutor_dashboard_page_permalink( 'reviews' ) ); ?>"> <?php esc_html_e( 'Received', 'tutor' ); ?> (<?php echo $received_count; ?>)</a> |
| 35 | </li> |
| 36 | <li class="tutor-nav-item"> |
| 37 | <a class="tutor-nav-link is-active" href="<?php echo esc_url( tutor_utils()->get_tutor_dashboard_page_permalink( 'reviews/given-reviews' ) ); ?>"> <?php esc_html_e( 'Given', 'tutor' ); ?> (<?php echo $review_count; ?>)</a> |
| 38 | </li> |
| 39 | </ul> |
| 40 | </div> |
| 41 | <?php endif; ?> |
| 42 | |
| 43 | <div class="tutor-dashboard-reviews-wrap"> |
| 44 | <?php if ( ! is_array( $reviews ) || ! count( $reviews ) ) : ?> |
| 45 | <div class="tutor-dashboard-content-inner"> |
| 46 | <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?> |
| 47 | </div> |
| 48 | <?php endif; ?> |
| 49 | |
| 50 | <div class="tutor-dashboard-reviews"> |
| 51 | <?php |
| 52 | foreach ( $reviews as $review ) : |
| 53 | $profile_url = tutor_utils()->profile_url( $review->user_id, false ); |
| 54 | $update_id = 'tutor_review_update_' . $review->comment_ID; |
| 55 | $delete_id = 'tutor_review_delete_' . $review->comment_ID; |
| 56 | $row_id = 'tutor_review_row_' . $review->comment_ID; |
| 57 | ?> |
| 58 | <div id="<?php echo esc_html( $row_id ); ?>" class="tutor-card tutor-dashboard-single-review tutor-review-<?php echo esc_html( $review->comment_ID ); ?> tutor-mb-32"> |
| 59 | <div class="tutor-card-header"> |
| 60 | <h4 class="tutor-card-title"> |
| 61 | <?php esc_html_e( 'Course: ', 'tutor' ); ?> |
| 62 | <span class="tutor-fs-6 tutor-fw-medium" data-href="<?php echo esc_url( get_the_permalink( $review->comment_post_ID ) ); ?>"> |
| 63 | <?php esc_html_e( get_the_title( $review->comment_post_ID ) ); ?> |
| 64 | </span> |
| 65 | </h4> |
| 66 | </div> |
| 67 | |
| 68 | <div class="tutor-card-body"> |
| 69 | <div class="tutor-row tutor-align-center tutor-mb-24"> |
| 70 | <div class="tutor-col"> |
| 71 | <?php tutor_utils()->star_rating_generator_v2( $review->rating, null, true ); ?> |
| 72 | </div> |
| 73 | |
| 74 | <div class="tutor-col-auto"> |
| 75 | <div class="tutor-given-review-actions tutor-d-flex"> |
| 76 | <span class="tutor-btn tutor-btn-ghost" data-tutor-modal-target="<?php echo esc_html( $update_id ); ?>" role="button"> |
| 77 | <i class="tutor-icon-edit tutor-mr-8" area-hidden="true"></i> |
| 78 | <span><?php esc_html_e( 'Edit', 'tutor' ); ?></span> |
| 79 | </span> |
| 80 | |
| 81 | <span class="tutor-btn tutor-btn-ghost tutor-ml-16" data-tutor-modal-target="<?php echo esc_html( $delete_id ); ?>" role="button"> |
| 82 | <i class="tutor-icon-trash-can-line tutor-mr-8" area-hidden="true"></i> |
| 83 | <span><?php esc_html_e( 'Delete', 'tutor' ); ?></span> |
| 84 | </span> |
| 85 | </div> |
| 86 | </div> |
| 87 | </div> |
| 88 | |
| 89 | <div class="tutor-fs-6 tutor-color-muted"> |
| 90 | <?php echo htmlspecialchars( stripslashes( $review->comment_content ) ); ?> |
| 91 | </div> |
| 92 | </div> |
| 93 | |
| 94 | <!-- Edit Review Modal --> |
| 95 | <form class="tutor-modal" id="<?php echo esc_html( $update_id ); ?>"> |
| 96 | <div class="tutor-modal-overlay"></div> |
| 97 | <div class="tutor-modal-window"> |
| 98 | <div class="tutor-modal-content tutor-modal-content-white"> |
| 99 | <button class="tutor-iconic-btn tutor-modal-close-o" data-tutor-modal-close> |
| 100 | <span class="tutor-icon-times" area-hidden="true"></span> |
| 101 | </button> |
| 102 | |
| 103 | <div class="tutor-modal-body tutor-text-center"> |
| 104 | <div class="tutor-fs-3 tutor-fw-medium tutor-color-black tutor-mt-48 tutor-mb-12"><?php _e("How would you rate this course?", "tutor"); ?></div> |
| 105 | <div class="tutor-fs-6 tutor-color-muted"><?php _e('Select Rating', 'tutor'); ?></div> |
| 106 | |
| 107 | <input type="hidden" name="course_id" value="<?php echo esc_html( $review->comment_post_ID ); ?>"/> |
| 108 | <input type="hidden" name="review_id" value="<?php echo esc_html( $review->comment_ID ); ?>"/> |
| 109 | <input type="hidden" name="action" value="tutor_place_rating" /> |
| 110 | |
| 111 | <div class="tutor-ratings tutor-ratings-xl tutor-ratings-selectable tutor-justify-center tutor-mt-16" tutor-ratings-selectable> |
| 112 | <?php |
| 113 | tutor_utils()->star_rating_generator( tutor_utils()->get_rating_value( $review->rating ) ); |
| 114 | ?> |
| 115 | </div> |
| 116 | |
| 117 | <textarea class="tutor-form-control tutor-mt-28" name="review" placeholder="<?php _e( 'write a review', 'tutor' ); ?>"><?php esc_html_e( stripslashes( $review->comment_content ) ); ?></textarea> |
| 118 | |
| 119 | <div class="tutor-d-flex tutor-justify-center tutor-my-48"> |
| 120 | <button type="button" class="tutor-btn tutor-btn-outline-primary" data-tutor-modal-close data-action="back"> |
| 121 | <?php esc_html_e( 'Cancel', 'tutor' ); ?> |
| 122 | </button> |
| 123 | <button type="submit" class="tutor_submit_review_btn tutor-btn tutor-btn-primary tutor-ml-20" data-action="next"> |
| 124 | <?php esc_html_e( 'Update Review', 'tutor' ); ?> |
| 125 | </button> |
| 126 | </div> |
| 127 | </div> |
| 128 | </div> |
| 129 | </div> |
| 130 | </form> |
| 131 | |
| 132 | <!-- Delete Modal --> |
| 133 | <?php |
| 134 | tutor_load_template( 'modal.confirm', array( |
| 135 | 'id' => $delete_id, |
| 136 | 'image' => 'icon-trash.svg', |
| 137 | 'title' => __('Do You Want to Delete This Review?', 'tutor'), |
| 138 | 'content' => __('Are you sure you want to delete this review permanently from the site? Please confirm your choice.', 'tutor'), |
| 139 | 'yes' => array( |
| 140 | 'text' => __('Yes, Delete This', 'tutor'), |
| 141 | 'class' => 'tutor-list-ajax-action', |
| 142 | 'attr' => array('data-request_data=\'{"action":"delete_tutor_review", "review_id":"' . $review->comment_ID . '"}\'', 'data-delete_element_id="' . $row_id . '"') |
| 143 | ), |
| 144 | )); |
| 145 | ?> |
| 146 | </div> |
| 147 | <?php endforeach; ?> |
| 148 | </div> |
| 149 | </div> |
| 150 | </div> |
| 151 | <?php |
| 152 | if($all_reviews->count > $per_page) { |
| 153 | $pagination_data = array( |
| 154 | 'total_items' => $all_reviews->count, |
| 155 | 'per_page' => $per_page, |
| 156 | 'paged' => $current_page, |
| 157 | ); |
| 158 | $pagination_template_frontend = tutor()->path . 'templates/dashboard/elements/pagination.php'; |
| 159 | tutor_load_template_from_custom_path( $pagination_template_frontend, $pagination_data ); |
| 160 | } |
| 161 | ?> |