quiz_report_table_strings
Filters the strings used in the quiz report table, allowing for translation and customization before display.
add_filter( 'quiz_report_table_strings', $callback, 10, 1 );
Description
This filter hook `quiz_report_table_strings` allows developers to modify the localized strings used in the frontend quiz report table. It fires just before the table strings are outputted, enabling customization of labels, messages, and other text elements displayed to users. The `$i18n` parameter contains an array of these strings.
Usage
add_filter( 'quiz_report_table_strings', 'your_function_name', 10, 1 );
Parameters
-
$i18n(mixed) - This parameter contains an array of localized strings used for the quiz report table's front-end display, including pagination information.
Return Value
The filtered value.
Examples
/**
* Example of modifying the localized strings for the quiz report table.
*
* This function demonstrates how to hook into the 'quiz_report_table_strings'
* filter to add or modify strings used in the front-end quiz report table.
*
* @param array $i18n The array of localized strings.
* @return array The modified array of localized strings.
*/
function my_custom_quiz_report_strings( $i18n ) {
// Add a new custom string for a specific scenario, e.g., when no data is available yet.
$i18n['table_language']['noDataAvailable'] = __( 'No quiz data available. Please complete a quiz to see your results.', 'my-text-domain' );
// Modify an existing string, for example, to change the placeholder text for the search input.
$i18n['table_language']['searchPlaceholder'] = __( 'Filter by quiz title, user, or completion date', 'my-text-domain' );
// Add a new button label for a potential future export option.
$i18n['buttons']['exportPDF'] = __( 'Export to PDF', 'my-text-domain' );
// You can also modify nested arrays. For instance, changing the "First" pagination label.
$i18n['table_language']['paginate']['first'] = __( 'Go to First Page', 'my-text-domain' );
// Return the modified array of strings.
return $i18n;
}
add_filter( 'quiz_report_table_strings', 'my_custom_quiz_report_strings', 10, 1 );
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/learndash/frontend-reports/group-quiz-report.php:644
private function get_frontend_localized_strings() {
$i18n = array(
'table_language' => array(
'info' => sprintf(
/* translators: %1$s is the start number, %2$s is the end number, and %3$s is the total number of entries */
_x( 'Showing %1$s to %2$s of %3$s entries', '%1$s is the start number, %2$s is the end number, and %3$s is the total number of entries', 'uncanny-learndash-reporting' ),
'_START_',
'_END_',
'_TOTAL_'
),
'infoEmpty' => __( 'Showing 0 to 0 of 0 entries', 'uncanny-learndash-reporting' ),
'infoFiltered' => sprintf(
/* translators: %s is a number */
_x( '(filtered from %s total entries)', '%s is a number', 'uncanny-learndash-reporting' ),
'_MAX_'
),
'infoPostFix' => '',
'lengthMenu' => sprintf(
/* translators: %s is a number */
_x( 'Show %s entries', 'Table', 'uncanny-learndash-reporting' ),
'_MENU_'
),
'loadingRecords' => __( 'Loading...', 'uncanny-learndash-reporting' ),
'processing' => __( 'Processing...', 'uncanny-learndash-reporting' ),
'search' => '_INPUT_',
'searchPlaceholder' => __( 'Search by username, name, email, date or score', 'uncanny-learndash-reporting' ),
'zeroRecords' => __( 'No quiz results found', 'uncanny-learndash-reporting' ),
'paginate' => array(
'first' => __( 'First', 'uncanny-learndash-reporting' ),
'last' => __( 'Last', 'uncanny-learndash-reporting' ),
'next' => __( 'Next', 'uncanny-learndash-reporting' ),
'previous' => __( 'Previous', 'uncanny-learndash-reporting' ),
),
'aria' => array(
'sortAscending' => sprintf( ': %s', __( 'activate to sort column ascending', 'uncanny-learndash-reporting' ) ),
'sortDescending' => sprintf( ': %s', __( 'activate to sort column descending', 'uncanny-learndash-reporting' ) ),
),
),
'customColumnLabels' => array(
'customizeColumns' => __( 'Customize columns', 'uncanny-learndash-reporting' ),
'hideCustomizeColumns' => __( 'Hide customize columns', 'uncanny-learndash-reporting' ),
),
'buttons' => array(
'csv' => __( 'CSV', 'uncanny-learndash-reporting' ),
'exportCSV' => __( 'CSV export', 'uncanny-learndash-reporting' ),
'excel' => __( 'Excel', 'uncanny-learndash-reporting' ),
'exportExcel' => __( 'Excel export', 'uncanny-learndash-reporting' ),
),
'all' => __( 'All', 'uncanny-learndash-reporting' ),
'noQuizResults' => __( 'No results', 'uncanny-learndash-reporting' ),
'cssSelectors' => array(
'labelLoading' => 'label-loading',
'tableLoading' => 'reporting-status-loading-animation-wrap',
),
);
return apply_filters( 'quiz_report_table_strings', $i18n );
}