Skip to content

Instantly share code, notes, and snippets.

@cristianstan
Created September 28, 2017 13:40
Show Gist options
  • Save cristianstan/2782f1edb2e9045485b2bedeb5bc712e to your computer and use it in GitHub Desktop.
Save cristianstan/2782f1edb2e9045485b2bedeb5bc712e to your computer and use it in GitHub Desktop.
<?php
$course = LP_Course::get_course( get_the_ID() );
// SECTIONS / MODULES
$sections = $course->get_curriculum();
if ( $sections ) {
$items = $course->get_curriculum_items( array( 'group' => true ) );
$count_sections = sizeof( $sections );
$count_lessons = sizeof( $items['lessons'] );
$count_quizzes = sizeof( $items['quizzes'] );
$output = sprintf( _nx( '%d section', '%d sections', $count_sections, 'learnpress' ), $count_sections );
$output .= ' (';
if ( $count_lessons ) {
$output .= sprintf( _nx( '%d lesson', '%d lessons', $count_lessons, 'learnpress' ), $count_lessons );
} else {
$output .= __( "0 lesson", 'learnpress' );
}
$output .= ', ';
if ( $count_quizzes ) {
$output .= sprintf( _nx( '%d quiz', '%d quizzes', $count_quizzes, 'learnpress' ), $count_quizzes );
} else {
$output .= __( "0 quiz", 'learnpress' );
}
$output .= ')';
echo $output;
} else {
_e( 'No content', 'learnpress' );
}
echo "<br />";
echo "<br />";
// PRICE
$price = get_post_meta( get_the_ID(), '_lp_price', true );
$is_paid = get_post_meta( get_the_ID(), '_lp_payment', true );
if ( ( $is_paid === 'yes' ) && $price ) {
echo sprintf( '<a href="%s">%s</a>', add_query_arg( 'filter_price', $price ), learn_press_format_price( get_post_meta( get_the_ID(), '_lp_price', true ), true ) );
} else {
echo sprintf( '<a href="%s">%s</a>', add_query_arg( 'filter_price', 0 ), __( 'Free', 'learnpress' ) );
}
echo "<br />";
echo "<br />";
// STUDENTS ENROLLED
echo '<span class=lp-label-counter>' . count( $course->get_students_list( true ) ) . '</span>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment