Skip to content

Commit

Permalink
Merge pull request #2396 from actuallyakash/issue/2365
Browse files Browse the repository at this point in the history
Added filter for updating text when not enrolled in any course
  • Loading branch information
eri-trabiccolo authored Apr 21, 2023
2 parents 22cd094 + 3bfb4f7 commit c46821c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .changelogs/issue_2365-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
significance: patch
type: dev
comment: Added hook `lifterlms_dashboard_memberships_not_enrolled_text` for
updating text when user is not enrolled in any memberships.
links:
- "#2396"
entry: Added `lifterlms_dashboard_memberships_not_enrolled_text` filter hook to
allow altering the message displaying on the dashboard when the current user
is not enrolled in any memberships.
7 changes: 7 additions & 0 deletions .changelogs/issue_2365.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
significance: patch
type: dev
comment: Added filter to change the text to be displayed when the student is not
enrolled in any courses.
links:
- "#2396"
entry: Added `lifterlms_dashboard_courses_not_enrolled_text` filter hook to allow altering the message displaying on the dashboard when the current user is not enrolled in any courses.
32 changes: 29 additions & 3 deletions includes/functions/llms.functions.templates.dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package LifterLMS/Functions
*
* @since 3.0.0
* @version 6.3.0
* @version [version]
*/

defined( 'ABSPATH' ) || exit;
Expand Down Expand Up @@ -162,6 +162,7 @@ function lifterlms_student_dashboard( $options = array() ) {
* @since 3.26.3 Unknown.
* @since 3.37.15 Added secondary sorting by `post_title` when the primary sort is `menu_order`.
* @since 6.3.0 Fix paged query not working when using plain permalinks.
* @since [version] Added filter for filtering 'Not enrolled text'.
*
* @param LLMS_Student $student Optional. LLMS_Student (current student if none supplied). Default `null`.
* @param bool $preview Optional. If true, outputs a short list of courses (based on dashboard_recent_courses filter). Default `false`.
Expand Down Expand Up @@ -193,7 +194,19 @@ function lifterlms_template_my_courses_loop( $student = null, $preview = false )

if ( ! $courses['results'] ) {

printf( '<p>%s</p>', __( 'You are not enrolled in any courses.', 'lifterlms' ) );
printf(
'<p>%s</p>',
/**
* Not enrolled text.
*
* Allows developers to filter the text to be displayed when the student is not enrolled in any courses.
*
* @since [version]
*
* @param string $not_enrolled_text The text to be displayed when the student is not enrolled in any course.
*/
apply_filters( 'lifterlms_dashboard_courses_not_enrolled_text', esc_html__( 'You are not enrolled in any courses.', 'lifterlms' ) )
);

} else {

Expand Down Expand Up @@ -283,6 +296,7 @@ function lifterlms_template_my_courses_loop( $student = null, $preview = false )
*
* @since 3.14.0
* @since 3.14.8 Unknown.
* @since [version] Added filter for filtering 'Not enrolled text'.
*
* @param LLMS_Student $student Optional. LLMS_Student (current student if none supplied). Default `null`.
* @return void
Expand All @@ -298,7 +312,19 @@ function lifterlms_template_my_memberships_loop( $student = null ) {

if ( ! $memberships ) {

printf( '<p>%s</p>', __( 'You are not enrolled in any memberships.', 'lifterlms' ) );
printf(
'<p>%s</p>',
/**
* Not enrolled text.
*
* Allows developers to filter the text to be displayed when the student is not enrolled in any memberships.
*
* @since [version]
*
* @param string $not_enrolled_text The text to be displayed when the student is not enrolled in any memberships.
*/
apply_filters( 'lifterlms_dashboard_memberships_not_enrolled_text', esc_html__( 'You are not enrolled in any memberships.', 'lifterlms' ) )
);

} else {

Expand Down

0 comments on commit c46821c

Please sign in to comment.