Created
December 19, 2019 00:15
-
-
Save adeel-raza/dfe5954182c73dc889b91b22c0f2669a to your computer and use it in GitHub Desktop.
Add new tag to lessons/topics/quizzes inside LeanrDash course table which are updated within 30 days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'learndash-lesson-row-title-after', 'learndash_add_tag_to_new_lessons', 10, 3); | |
function learndash_add_tag_to_new_lessons( $lesson_id, $course_id, $user_id ) { | |
$lesson = get_post( $lesson_id ); | |
if ( strtotime( $lesson->post_modified ) > strtotime( '-30 days' ) ) { | |
echo "<span class='ld-content-new-tag'>" . __( "(New)", 'sfwd-lms' ) . "</span>"; | |
} | |
} | |
add_action( 'learndash-topic-row-title-after', 'learndash_add_tag_to_new_topics', 10, 3); | |
function learndash_add_tag_to_new_topics( $topic_id, $course_id, $user_id ) { | |
$topic = get_post( $topic_id ); | |
if ( strtotime( $topic->post_modified ) > strtotime( '-30 days' ) ) { | |
echo "<span class='ld-content-new-tag'>" . __( "(New)", 'sfwd-lms' ) . "</span>"; | |
} | |
} | |
add_action( 'learndash-quiz-row-title-after', 'learndash_add_tag_to_new_quizzes', 10, 3); | |
function learndash_add_tag_to_new_quizzes( $quiz_id, $course_id, $user_id ) { | |
$quiz = get_post( $quiz_id ); | |
if ( strtotime( $quiz->post_modified ) > strtotime( '-30 days' ) ) { | |
echo "<span class='ld-content-new-tag'>" . __( "(New)", 'sfwd-lms' ) . "</span>"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place this snippet in your theme's functions.php file and a New tag will be displayed next to lessons/topcis/quizzes inside the LeanrDash course content table on the course page.
Please note that a CSS class is added to all the new tags
.ld-content-new-tag
so that you can easily design the look and feel by adding CSS rules in your theme's custom CSS