Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing number of lessons in Course Catalog and My Courses. #2439

Merged
merged 9 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changelogs/issues_2434.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
significance: minor
type: added
links:
- "#2434"
entry: Added a paragraph to show Number of lessons in a course at Course Catalog
and My Courses.
18 changes: 17 additions & 1 deletion includes/functions/llms.functions.templates.loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package LifterLMS/Functions
*
* @since 1.0.0
* @version 7.1.3
* @version [version]
*/

defined( 'ABSPATH' ) || exit;
Expand Down Expand Up @@ -346,6 +346,22 @@ function lifterlms_template_loop_difficulty() {
}
}

/**
* Count of Total Lessons in a Course.
eri-trabiccolo marked this conversation as resolved.
Show resolved Hide resolved
*
* @since [version]
*
* @return void.
*/
if ( ! function_exists( 'lifterlms_template_loop_lesson_count' ) ) {

function lifterlms_template_loop_lesson_count() {
if ( 'course' === get_post_type( get_the_ID() ) ) {
llms_get_template( 'course/lesson-count.php' );
}
}
}

/**
* Show enrollment date meta
* used on Dashboard only
Expand Down
3 changes: 2 additions & 1 deletion includes/llms.template.hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @package LifterLMS/Hooks
*
* @since 1.0.0
* @version 6.0.0
* @version [version]
*/

defined( 'ABSPATH' ) || exit;
Expand Down Expand Up @@ -79,6 +79,7 @@
add_action( 'lifterlms_after_loop_item_title', 'lifterlms_template_loop_author', 10 );
add_action( 'lifterlms_after_loop_item_title', 'lifterlms_template_loop_length', 15 );
add_action( 'lifterlms_after_loop_item_title', 'lifterlms_template_loop_difficulty', 20 );
add_action( 'lifterlms_after_loop_item_title', 'lifterlms_template_loop_lesson_count', 25 );

add_action( 'lifterlms_after_loop_item', 'lifterlms_loop_link_end', 5 );

Expand Down
1 change: 0 additions & 1 deletion templates/course/length.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@
<div class="llms-meta llms-course-length">
<p><?php printf( __( 'Estimated Time: <span class="length">%s</span>', 'lifterlms' ), $course->get( 'length' ) ); ?></p>
</div>

eri-trabiccolo marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 24 additions & 0 deletions templates/course/lesson-count.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Lessons count in a Course.
*
* @package LifterLMS/Templates
*
* @since [version]
* @version [version]
*
* @author LifterLMS
* @package LifterLMS/Templates
*/
eri-trabiccolo marked this conversation as resolved.
Show resolved Hide resolved

defined( 'ABSPATH' ) || exit;

global $post;

$course = new LLMS_Course( $post );
$lessons_count = $course->get_lessons_count();
eri-trabiccolo marked this conversation as resolved.
Show resolved Hide resolved
?>

<div class="llms-meta llms-lessons-count">
<p><?php printf( __( 'Number of Lessons: <span class="lessons-count">%u</span>', 'lifterlms' ), $lessons_count ); ?></p>
eri-trabiccolo marked this conversation as resolved.
Show resolved Hide resolved
</div>
eri-trabiccolo marked this conversation as resolved.
Show resolved Hide resolved