lifterlms_template_certificates_loop( $student = null,  $limit = false )


Source Source

File: includes/functions/llms.functions.templates.certificates.php

	function lifterlms_template_certificates_loop( $student = null, $limit = false ) {

		// Get the current student if none supplied.
		if ( ! $student ) {
			$student = llms_get_student();
		}

		// Don't proceed without a student.
		if ( ! $student ) {
			return;
		}

		$cols     = llms_get_certificates_loop_columns();
		$per_page = $cols * 5;

		// Get certificates.
		$query        = $student->get_certificates(
			array(
				'page'     => max( 1, get_query_var( 'paged' ) ),
				'per_page' => $limit ? min( $limit, $per_page ) : $per_page,
			)
		);
		$certificates = $query->get_awards();

		/**
		 * If no columns are specified and we have a specified limit
		 * and results and the limit is less than the number of columns
		 * force the columns to equal the limit.
		 */
		if ( $limit && $limit < $cols && $query->get_number_results() ) {
			$cols = $limit;
		}

		$pagination = 'dashboard' === LLMS_Student_Dashboard::get_current_tab( 'slug' ) ? false : array(
			'total'   => $query->get_max_pages(),
			'context' => 'student_dashboard',
		);

		llms_get_template(
			'certificates/loop.php',
			compact( 'cols', 'certificates', 'pagination' )
		);

	}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.