Ajax::dozent_load_more_reviews()

Load more reviews


Description

Ajax pagination of the reviews which comes from the course details page.


Source

File: classes/Ajax.php

	public function dozent_load_more_reviews() {

		$course_id = dozent_input_text( 'course_id' );
		$per_page  = dozent_input_text( 'per_page' );
		$page      = max( 1, dozent_input_text( 'page' ) );
		$start     = ( $page - 1 ) * $per_page;

		//search term
		$review_s        = dozent_input_text( 'review_s' );
		$review_s_rating = (int) dozent_input_text( 'review_s_rating' );

		$search_args = [ 'course_id' => $course_id, 'start' => $start, 'per_page' => $per_page ];

		//search term
		if ( $review_s ) {
			$search_args['s'] = $review_s;
		}

		//Filter by rating
		if ( $review_s_rating ) {
			$search_args['rating'] = $review_s_rating;
		}

		$reviews = dozent_get_course_reviews( $search_args );

		$review_html = '';
		if ( $reviews->count ) {
			foreach ( $reviews->results as $review ) {
				$review_html .= dozent_individual_review_render( $review, false );
			}
		}

		wp_send_json_success( [ 'html' => $review_html ] );
	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.