uo_pro_transcript_cumulative_column
Filters the cumulative column data for transcripts, allowing modification before it's displayed.
add_filter( 'uo_pro_transcript_cumulative_column', $callback, 10, 2 );
Description
Allows developers to modify or add custom cumulative columns to the Uncanny Automator Pro transcript. This filter fires when generating transcript data, enabling the injection of additional key-value pairs for custom reporting or integration purposes. The `$key` and `$transcript` parameters provide context for each transcript entry.
Usage
add_filter( 'uo_pro_transcript_cumulative_column', 'your_function_name', 10, 2 );
Parameters
-
$key(mixed) - This parameter represents the cumulative column data itself, which is initially an empty array and can be modified by filters.
-
$transcript(mixed) - This parameter represents the unique identifier or key for the current transcript entry being processed.
Return Value
The filtered value.
Examples
<?php
/**
* Example function to add a custom column to the Uncanny Pro Transcript cumulative data.
*
* This function demonstrates how to hook into 'uo_pro_transcript_cumulative_column'
* to add a new cumulative data point for a specific transcript key.
*
* @param array $cumulative_columns An array of existing cumulative column data.
* @param mixed $key The current transcript key being processed.
* @param object $transcript The current transcript object.
* @return array The modified array of cumulative column data.
*/
function my_custom_transcript_cumulative_column( $cumulative_columns, $key, $transcript ) {
// Example: Only add a custom column for a specific course or lesson key.
// Replace 'your_specific_course_lesson_key' with the actual key you want to target.
if ( 'your_specific_course_lesson_key' === $key ) {
// You can dynamically calculate or retrieve data here.
// For demonstration, let's assume we have a meta field storing some value.
$custom_value = get_post_meta( $transcript->ID, '_my_custom_transcript_data', true );
// Ensure we have a value before adding the column.
if ( ! empty( $custom_value ) ) {
$cumulative_columns[ $key ] = array(
'title' => __( 'Custom Data Points', 'your-text-domain' ), // The title for the column header.
'value' => sanitize_text_field( $custom_value ), // The actual data value to display.
);
}
}
// Always return the potentially modified array.
return $cumulative_columns;
}
// Add the filter to WordPress.
// The third parameter '3' indicates that this callback function accepts 3 arguments.
add_filter( 'uo_pro_transcript_cumulative_column', 'my_custom_transcript_cumulative_column', 10, 3 );
?>
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/templates/transcript.php:183
data-column="<?php esc_attr_e( 'Total Final Score', 'uncanny-pro-toolkit' ); ?>">
<?php echo $final_quiz_score; ?>
</div>
<?php
} else {
$custom_cumulative_column = apply_filters( 'uo_pro_transcript_cumulative_column', array(), $key, $transcript );
if (
! empty( $custom_cumulative_column )
&& isset( $custom_cumulative_column[ $key ] )
&& isset( $custom_cumulative_column[ $key ]['title'] )
&& isset( $custom_cumulative_column[ $key ]['value'] )
) {