Last active
August 16, 2021 01:00
-
-
Save adeel-raza/4b8427b137ad95c03ef58279821447bd to your computer and use it in GitHub Desktop.
Add lesson/topic ID as a link title to lessons/topics names inside LearnDash course table
This file contains hidden or 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-before', 'custom_add_title_to_course_lesson_table', 10, 3); | |
function custom_add_title_to_course_lesson_table( $lesson_id, $course_id, $user_id ) { | |
if( ! current_user_can('group_leader') && ! current_user_can('administrator') ) { | |
return; | |
} | |
wp_add_inline_script( 'learndash-front', | |
'if( jQuery("#ld-expand-'.esc_html( $lesson_id ).'").length != 0 ) { | |
jQuery("#ld-expand-'.esc_html( $lesson_id ).'").find(".ld-item-name").attr("title", '.esc_attr( $lesson_id ).') | |
}' | |
); | |
} | |
add_action( 'learndash-topic-row-title-before', 'custom_add_title_to_course_topic_table', 10, 3); | |
function custom_add_title_to_course_topic_table( $topic_id, $course_id, $user_id ) { | |
if( ! current_user_can('group_leader') && ! current_user_can('administrator') ) { | |
return; | |
} | |
wp_add_inline_script( 'learndash-front', | |
'if( jQuery("#ld-table-list-item-'.esc_html( $topic_id ).'").length != 0 ) { | |
jQuery("#ld-table-list-item-'.esc_html( $topic_id ).'").find(".ld-topic-row").attr("title", '.esc_attr( $topic_id ).') | |
}' | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The solution is derived from the feature request here https://facebook.com/groups/1020920397944393/permalink/2582968935072857
Place this snippet in your theme's functions.php file and a link title with the topic/lesson ID will be added inside the LeanrDash course content table with each lesson and topic