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