Skip to content

Commit

Permalink
Merge pull request #590 from themeum/harun
Browse files Browse the repository at this point in the history
fix - review popup
  • Loading branch information
shewa12 authored Oct 12, 2023
2 parents 2c67225 + 774d71b commit 1ffe764
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion assets/react/lib/modules/instructor-review.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ window.jQuery(document).ready($ => {
*
* @since 2.4.0
*/
$(document).on('click','.tutor-course-review-popup-form .tutor-modal-close-o', function() {
$(document).on('click','.tutor-course-review-popup-form .tutor-modal-close-o, .tutor-course-review-popup-form .tutor-review-popup-cancel', function() {
let modal = $(this).closest('.tutor-modal');
let course_id = modal.find('input[name="course_id"]').val();
let data = {
Expand Down
14 changes: 9 additions & 5 deletions classes/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,8 @@ public static function set_review_popup_data( $user_id, $course_id ) {
if ( get_tutor_option( 'enable_course_review' ) ) {
$rating = tutor_utils()->get_course_rating_by_user( $course_id, $user_id );
if ( ! $rating || ( empty( $rating->rating ) && empty( $rating->review ) ) ) {
add_user_meta( $user_id, User::REVIEW_POPUP_META, $course_id );
$meta_key = User::REVIEW_POPUP_META . '_' . $course_id;
add_user_meta( $user_id, $meta_key, $course_id );
}
}
}
Expand All @@ -870,10 +871,12 @@ public static function set_review_popup_data( $user_id, $course_id ) {
*/
public function popup_review_form() {
if ( is_user_logged_in() ) {
$user_id = get_current_user_id();
$course_id = (int) get_user_meta( $user_id, User::REVIEW_POPUP_META, true );
$user_id = get_current_user_id();
$course_id = get_the_ID();
$meta_key = User::REVIEW_POPUP_META . '_' . $course_id;
$review_course_id = (int) get_user_meta( $user_id, $meta_key, true );

if ( is_single() && get_the_ID() === $course_id ) {
if ( is_single() && $course_id === $review_course_id ) {
include tutor()->path . 'views/modal/review.php';
}
}
Expand All @@ -894,7 +897,8 @@ public function clear_review_popup_data() {
$course_id = Input::post( 'course_id', 0, Input::TYPE_INT );

if ( $course_id ) {
delete_user_meta( $user_id, User::REVIEW_POPUP_META, $course_id );
$meta_key = User::REVIEW_POPUP_META . '_' . $course_id;
delete_user_meta( $user_id, $meta_key, $course_id );
}

wp_send_json_success();
Expand Down
2 changes: 1 addition & 1 deletion views/modal/review.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<textarea name="review" class="tutor-form-control tutor-mt-28" placeholder="<?php esc_attr_e( 'Tell us about your own personal experience taking this course. Was it a good match for you?', 'tutor' ); ?>"></textarea>

<div class="tutor-d-flex tutor-justify-center tutor-my-48">
<button type="button" class="tutor-btn tutor-btn-outline-primary" data-tutor-modal-close>
<button type="button" class="tutor-review-popup-cancel tutor-btn tutor-btn-outline-primary">
<?php esc_html_e( 'Cancel', 'tutor' ); ?>
</button>
<button type="submit" class="tutor_submit_review_btn tutor-btn tutor-btn-primary tutor-ml-20">
Expand Down

0 comments on commit 1ffe764

Please sign in to comment.