uo_transcript_print_styles
Filters the assets to be included when printing transcripts to control their styles.
add_filter( 'uo_transcript_print_styles', $callback, 10, 1 );
Description
Filters the array of CSS and JavaScript assets enqueued for the Uncanny Toolkit's transcript functionality. Developers can use this hook to modify or replace the default asset URLs, allowing for custom styling or JavaScript modifications for the transcript display.
Usage
add_filter( 'uo_transcript_print_styles', 'your_function_name', 10, 1 );
Parameters
-
$assets(mixed) - This parameter is an array containing the URLs for the CSS and JavaScript files required for the transcript display.
Return Value
The filtered value.
Examples
/**
* Modify the transcript print styles to include an additional custom CSS file.
*
* This example demonstrates how to hook into 'uo_transcript_print_styles'
* to add a custom stylesheet that will be applied when the transcript is printed.
*
* @param array $print_styles An array of CSS URLs to be used for printing the transcript.
* @return array The modified array of CSS URLs.
*/
add_filter(
'uo_transcript_print_styles',
function ( $print_styles ) {
// Get the URL of a custom stylesheet for transcript printing.
$custom_print_style_url = plugins_url( 'assets/css/custom-transcript-print.css', __FILE__ );
// Add the custom stylesheet URL to the existing array.
$print_styles[] = $custom_print_style_url . '?v=' . UNCANNY_TOOLKIT_PRO_VERSION;
return $print_styles;
},
10, // Priority
1 // Accepted arguments
);
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/classes/learn-dash-transcript.php:1160
public static function enqueue_scripts() {
// Get the URL of the assets
$assets = array(
'css' => plugins_url( basename( dirname( UO_FILE ) ) ) . '/src/assets/legacy/frontend/css/transcript.css',
'js' => plugins_url( basename( dirname( UO_FILE ) ) ) . '/src/assets/legacy/frontend/js/transcript.js',
);
// Enqueue stylesheet
wp_enqueue_style(
'ultp-transcript',
$assets['css'],
array(),
UNCANNY_TOOLKIT_PRO_VERSION
);
// Enqueue the JS
wp_enqueue_script(
'ultp-transcript',
$assets['js'],
array(),
UNCANNY_TOOLKIT_PRO_VERSION,
true
);
// Get the list of styles that we'll use to print the transcript
$print_version_styles = apply_filters( 'uo_transcript_print_styles', array(
$assets['css'] . '?v=' . UNCANNY_TOOLKIT_PRO_VERSION,
) );
// Get the list of elements/nodes that we'll clone when printing the transcript
$print_version_elements = apply_filters( 'uo_transcript_print_elements', array(
'#ultp-transcript-css-extra',
) );
// Localize the script with the data
wp_localize_script(
'ultp-transcript',
'ULTP_Transcript',
array(
'print_version_styles' => $print_version_styles,
'print_version_elements' => $print_version_elements,
)
);
}