Addons.php
4 years ago
Admin.php
4 years ago
Ajax.php
4 years ago
Announcements.php
4 years ago
Assets.php
4 years ago
Backend_Page_Trait.php
4 years ago
Course.php
4 years ago
Course_Filter.php
4 years ago
Course_List.php
4 years ago
Course_Settings_Tabs.php
4 years ago
Course_Widget.php
4 years ago
Custom_Validation.php
5 years ago
Dashboard.php
4 years ago
FormHandler.php
4 years ago
Frontend.php
4 years ago
Gutenberg.php
4 years ago
Instructor.php
4 years ago
Instructors_List.php
4 years ago
Lesson.php
4 years ago
Options_V2.php
4 years ago
Post_types.php
4 years ago
Private_Course_Access.php
4 years ago
Q_and_A.php
4 years ago
Question_Answers_List.php
4 years ago
Quiz.php
4 years ago
Quiz_Attempts_List.php
4 years ago
RestAPI.php
4 years ago
Reviews.php
4 years ago
Rewrite_Rules.php
4 years ago
Shortcode.php
4 years ago
Student.php
4 years ago
Students_List.php
4 years ago
Taxonomies.php
4 years ago
Template.php
4 years ago
Theme_Compatibility.php
5 years ago
Tools.php
4 years ago
Tools_V2.php
4 years ago
Tutor.php
4 years ago
TutorEDD.php
4 years ago
Tutor_Base.php
5 years ago
Tutor_List_Table.php
4 years ago
Tutor_Setup.php
4 years ago
Upgrader.php
4 years ago
User.php
4 years ago
Utils.php
4 years ago
Video_Stream.php
4 years ago
Withdraw.php
4 years ago
Withdraw_Requests_List.php
4 years ago
WooCommerce.php
4 years ago
Reviews.php
76 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Tutor Ratings |
| 4 | * |
| 5 | * @package Ratings |
| 6 | * @since v2.0.0 |
| 7 | */ |
| 8 | |
| 9 | namespace TUTOR; |
| 10 | |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit; |
| 13 | } |
| 14 | /** |
| 15 | * Handle ratings related logics |
| 16 | */ |
| 17 | class Reviews { |
| 18 | |
| 19 | /** |
| 20 | * Handle actions & dependencies |
| 21 | * |
| 22 | * @since v2.0.0 |
| 23 | */ |
| 24 | public function __construct() { |
| 25 | /** |
| 26 | * Delete reviews action |
| 27 | */ |
| 28 | add_action( 'wp_ajax_tutor_delete_review', array( $this, 'delete_review' ) ); |
| 29 | add_action( 'wp_ajax_tutor_single_course_reviews_load_more', array($this, 'tutor_single_course_reviews_load_more') ); |
| 30 | add_action( 'wp_ajax_nopriv_tutor_single_course_reviews_load_more', array($this, 'tutor_single_course_reviews_load_more') ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Handle ajax request for deleting review |
| 35 | * |
| 36 | * @since v2.0.0 |
| 37 | */ |
| 38 | public function delete_review() { |
| 39 | tutor_utils()->checking_nonce(); |
| 40 | $review_id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : ''; |
| 41 | $delete = self::delete( $review_id ); |
| 42 | wp_send_json( $delete ); |
| 43 | exit; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Delete review |
| 48 | * |
| 49 | * @param int $id review id required. |
| 50 | * @return bool true or false. |
| 51 | * @since v2.0.0 |
| 52 | */ |
| 53 | public static function delete( int $id ): bool { |
| 54 | $id = sanitize_text_field( $id ); |
| 55 | global $wpdb; |
| 56 | $comment_table = $wpdb->comments; |
| 57 | $delete = $wpdb->delete( |
| 58 | $comment_table, |
| 59 | array( |
| 60 | 'comment_ID' => $id, |
| 61 | ) |
| 62 | ); |
| 63 | return $delete ? true : false; |
| 64 | } |
| 65 | |
| 66 | public function tutor_single_course_reviews_load_more() { |
| 67 | tutor_utils()->checking_nonce(); |
| 68 | |
| 69 | ob_start(); |
| 70 | tutor_load_template( 'single.course.reviews' ); |
| 71 | $html = ob_get_clean(); |
| 72 | |
| 73 | wp_send_json_success( array('html' => $html) ); |
| 74 | } |
| 75 | } |
| 76 |