_parent_file = __FILE__; add_action('init', array(&$__what_did_they_say_admin, 'init')); // template tags // please, if you use any of these, wrap them in function_exists() so your site doesn't // blow up if you disable the plugin! Example: // // if (function_exists('the_media_transcript')) { the_media_transcript(); } // /** * Get the transcript for the current post. * @param string $language The language code to use. If not specificed, use the default language. * @return string|false The transcript in the requested language for the specified post, or false if no transcript found. */ function get_the_media_transcript($language = null) { global $post; if (!empty($post)) { $language_options = new WDTSLanguageOptions(); if (is_null($language)) { $language = $language_options->get_default_language(); } $transcript = false; $approved_transcripts = new WDTSApprovedTranscript($post->ID); $transcripts = $approved_transcripts->get_transcripts(); if (!empty($transcripts)) { foreach ($transcripts as $transcript) { if ($transcript['language'] == $language) { return $transcript['transcript']; } } } return $transcript; } return ''; } /** * Show the transcript for the current post in the requested_language. * @param string $language The language code to use. If not specificed, use the default language. */ function the_media_transcript($language = null) { echo end(apply_filters('the_media_transcript', get_the_media_transcript($language))); } /** * Get the excerpt of all transcripts that match the provided search string. */ function get_the_matching_transcripts($search_string = '') { global $post; if (empty($search_string)) { $search_string = get_query_var('s'); } $approved_transcripts = new WDTSApprovedTranscript($post->ID); $transcripts = $approved_transcripts->get_transcripts(); $matching_transcripts = array(); if (!empty($transcripts)) { foreach ($transcripts as $transcript) { if (strpos($transcript['transcript'], $search_string) !== false) { $matching_transcripts[] = $transcript; } } } return $matching_transcripts; } function the_matching_transcript_excerpts($search_string = '') { if (empty($search_string)) { $search_string = get_query_var('s'); } echo end(apply_filters('the_matching_transcript_excerpts', get_the_matching_transcripts($search_string), $search_string)); } /** * Get the name of the language specified by the provided language code. * @param string $language The language code to use. If not specificed, use the default language. * @return string The name of the requested language. */ function get_the_language_name($language = null) { $language_options = new WDTSLanguageOptions(); if (is_null($language)) { $language = $language_options->get_default_language(); } return $language_options->get_language_name($language); } /** * Show the name of the language specified by the provided language code. * @param string $language The language code to use. If not specificed, use the default language. */ function the_language_name($language = null) { echo end(apply_filters('the_language_name', get_the_language_name($language))); } /** * Display all transcripts for a post, with a dropdown selector for people to select other languages. * @param string $dropdown_message If set, the text that appears to the left of the language dropdown. * @param string $single_language_message If set, the text that appears when only one transcript exists for this post. */ function transcripts_display($language_format = null, $show_transcripts_string = null, $hide_transcripts_string = null) { global $post; $output = array(); $transcripts = array(); $approved_transcripts = new WDTSApprovedTranscript($post->ID); $post_transcripts = $approved_transcripts->get_transcripts(); if (!empty($post_transcripts)) { foreach ($post_transcripts as $transcript) { $transcript_text = trim($transcript['transcript']); if (!empty($transcript_text)) { $transcripts[$transcript['language']] = $transcript; } } $language_options = new WDTSLanguageOptions(); $options = get_option('what-did-they-say-options'); if (count($transcripts) > 0) { $default_language = $language_options->get_default_language(); $do_hide = false; if (is_home() || is_single()) { foreach ($options['hide_transcript'] as $type => $do_hide) { if ($do_hide && call_user_func("is_${type}")) { $do_hide = true; break; } } } $output[] = '