Skip to content

Instantly share code, notes, and snippets.

@adeel-raza
Last active August 16, 2021 01:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adeel-raza/4b8427b137ad95c03ef58279821447bd to your computer and use it in GitHub Desktop.
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
<?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 ).')
}'
);
}
@adeel-raza
Copy link
Author

adeel-raza commented Dec 25, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment