lifterlms_template_certificates_loop( $student = null, $limit = false )
Contents
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' )
);
}
Expand full source code Collapse full source code View on GitHub