uo_tin_can_filter_course_label
Filters the label used for the "Course" filter group within the Tin Can reporting.
add_filter( 'uo_tin_can_filter_course_label', $callback, 10, 1 );
Description
This filter hook allows developers to modify the label displayed for the "Course" filter group within the Tin Can reporting. You can customize this label for better context or internationalization. The first parameter is the default label, and the second parameter is a boolean indicating whether the filter group is active (though this is typically intended for internal use).
Usage
add_filter( 'uo_tin_can_filter_course_label', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the uo_tin_can_filter_course_label filter.
*
* This filter allows you to change the label for the 'Course' filter in the Tin Can reporting.
* For instance, you might want to change it to 'Lesson' if your reporting focuses on lessons.
*
* @param string $label The current label for the course filter.
* @param mixed $default_value The default value passed to the filter (in this case, false).
*
* @return string The modified label for the course filter.
*/
add_filter( 'uo_tin_can_filter_course_label', 'my_custom_tin_can_course_label', 10, 2 );
function my_custom_tin_can_course_label( $label, $default_value ) {
// Check if we want to apply a custom label.
// For demonstration, let's change it to 'Training Module'.
$custom_label = 'Training Module';
// In a real-world scenario, you might check a user role, a specific setting,
// or a query parameter to decide whether to modify the label.
// For this example, we'll always change it.
// Ensure the custom label is escaped for safe output.
return esc_html( $custom_label );
}
?>
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/reporting/xapi-quiz/templates/xapi-quiz-filter.php:146
src/reporting/xapi-quiz/templates/xapi-quiz-filter.php:154
src/reporting/tin-can/templates/tc-tincan-filter.php:150
src/reporting/tin-can/templates/tc-tincan-filter.php:158
<div class="reporting-tincan-filters-col reporting-tincan-filters-col--2">
<div class="reporting-tincan-section__title">
<?php echo apply_filters( 'uo_tin_can_filter_content_label', esc_html_x( 'Content', 'Tin Can Filter Content label', 'uncanny-learndash-reporting' ) ); ?>
</div>
<div class="reporting-tincan-section__content">
<div class="reporting-tincan-section__field">
<label for="tc_filter_course"><?php echo ucfirst( apply_filters( 'uo_tin_can_filter_course_label', esc_html_x( 'Course', 'Tin Can Filter Group name', 'uncanny-learndash-reporting' ), false ) ); ?></label>
<select class="uo-admin-select" name="tc_filter_course" id="tc_filter_course">
<option value="">
<?php
echo esc_html(
sprintf(
/* translators: %s: Course label */
__( 'All %s', 'uncanny-learndash-reporting' ),