PluginProbe
Tutor LMS – eLearning and online course solution / 2.0.1
Tutor LMS – eLearning and online course solution v2.0.1
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
tutor / classes / Reviews.php

Reviews.php in Tutor LMS – eLearning and online course solution 2.0.1, at classes/Reviews.php

76 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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