Skip to main content

React when a transcript is formatted

Premium Intermediate

Format transcript stores an HTML version of a finished transcript in the background. To re-index it, purge a page cache, or notify someone when it lands:

  • Fires after the HTML is stored and the show’s feed cache cleared, once per successful run, Format again included. Not for a failed run, and not when a correction clears the formatted version (hook benecaster_transcript_updated for that).
  • It runs from Action Scheduler: no output, no current user. To read the formatted text, fetch the row and pass it through \BenecasterTranscription\Format\FormattedHtml::clean(), which removes the line markers a timed transcript’s version carries.
  • It says nothing about who may read the transcript: check benecaster_user_can_see_transcript() before showing the text to anyone.

Code

<?php
add_action( 'benecaster_transcript_formatted', function ( int $transcript_id, int $episode_id ): void {
    // The episode page now shows the formatted paragraphs: drop its cached copy.
    if ( function_exists( 'my_cache_purge_url' ) ) {
        my_cache_purge_url( get_permalink( $episode_id ) );
    }
}, 10, 2 );

View on GitHub →

Hooks Used

Need this built rather than just documented? See our services →