Action
tin-canny-learndash-reporting
uo_tincanny_reporting_questions_table_thead_afterbegin
Fires after the table head of the Tincanny reporting questions table has begun, allowing custom content insertion.
add_action( 'uo_tincanny_reporting_questions_table_thead_afterbegin', $callback, 10, 1 );
Description
Fires after the `
` tag is opened but before any columns are added to the Uncanny Toolkit's Question Analysis Report table. Developers can use this hook to add custom column headers or manipulate the existing ones.Usage
add_action( 'uo_tincanny_reporting_questions_table_thead_afterbegin', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Add a custom column to the Uncanny Toolkit Tincanny Questions Report table.
*
* This example demonstrates how to hook into 'uo_tincanny_reporting_questions_table_thead_afterbegin'
* to inject additional table header cells (`<th>`) into the report.
*
* @param array $columns The existing array of column IDs and their display names.
* @return array The modified array of column IDs and their display names.
*/
add_action( 'uo_tincanny_reporting_questions_table_thead_afterbegin', 'my_custom_tincanny_report_column', 10 );
function my_custom_tincanny_report_column() {
// In a real scenario, you'd likely be adding a new column definition here.
// For demonstration, we'll just echo an additional header.
// You might use this to add a "Notes" column, or a "Status" column, etc.
// Example: Adding a "Average Score" column
echo '<th class="report-header custom-average-score">Average Score</th>';
// If you were modifying self::$columns directly (which is generally discouraged
// for actions unless absolutely necessary and with careful consideration of scope),
// you would add your column definition like this:
//
// global $your_plugin_column_definitions; // Assuming your definitions are stored globally or accessible
// $your_plugin_column_definitions['average_score'] = 'Average Score';
//
// However, using do_action is the cleaner and more standard approach for adding to the output.
}
// Example of how to then handle the data for this new column in the table body.
// This would hook into a similar action within the table row generation.
// Let's assume there's a hook like 'uo_tincanny_reporting_questions_table_row_afterbegin' or similar
// where you can output the data for the new column.
// This is a hypothetical hook for demonstration purposes, as the provided context
// doesn't show the row generation part.
// add_action( 'uo_tincanny_reporting_questions_table_row_data_afterbegin', 'my_custom_tincanny_report_column_data', 10, 2 );
//
// function my_custom_tincanny_report_column_data( $question_id, $row_data ) {
// // Calculate or retrieve the average score for the question.
// // This is highly dependent on how Uncanny Toolkit stores and provides this data.
// $average_score = rand( 60, 100 ); // Placeholder for actual calculation
//
// echo '<td class="custom-average-score">' . esc_html( $average_score ) . '%</td>';
// }
?>
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/uncanny-question-analysis-report/question-analysis-report.php:901
?>
<?php do_action( 'uo_tincanny_reporting_questions_table_beforebegin' ); ?>
<table id="uotc-question-report" class="display responsive" cellspacing="0" width="100%">
<thead>
<tr>
<?php do_action( 'uo_tincanny_reporting_questions_table_thead_afterbegin' ); ?>
<?php foreach ( self::$columns as $id => $col ) { ?>
<th class="report-header <?php echo esc_attr( sanitize_title( $id ) ); ?>"><?php echo $col; ?></th>
<?php } ?>
<?php do_action( 'uo_tincanny_reporting_questions_table_thead_beforeend' ); ?>
</tr>