From 1eb372c15810caae6c2f3a4d0699ba520b28b4e4 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 16 Aug 2009 14:14:07 -0400 Subject: [PATCH] working on template tags --- classes/WhatDidTheySay.php | 20 ++++++++++++++++++++ what-did-they-say.php | 30 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/classes/WhatDidTheySay.php b/classes/WhatDidTheySay.php index 4fab6dd..4e8758f 100644 --- a/classes/WhatDidTheySay.php +++ b/classes/WhatDidTheySay.php @@ -231,6 +231,26 @@ class WhatDidTheySay { } } } + + function get_default_language() { + $language = false; + $options = get_option('what-did-they-say-options'); + foreach ($options['languages'] as $code => $info) { + if (is_null($language)) { $language = $code; } + if ($info['default']) { $language = $code; break; } + } + return $language; + } + + function get_language_name($language) { + $options = get_option('what-did-they-say-options'); + + if (isset($options['languages'][$language])) { + return $options['languages'][$language]['name']; + } else { + return false; + } + } } ?> diff --git a/what-did-they-say.php b/what-did-they-say.php index 7999fd8..cb1b648 100644 --- a/what-did-they-say.php +++ b/what-did-they-say.php @@ -33,4 +33,34 @@ add_action('init', array(&$what_did_they_say_admin, 'init')); register_activation_hook(__FILE__, array(&$what_did_they_say, 'install')); register_activation_hook(__FILE__, array(&$what_did_they_say_admin, 'install')); +function get_the_media_transcript($language = null) { + global $post, $what_did_they_say; + + if (is_null($language)) { $language = $what_did_they_say->get_default_language(); } + + $transcript = false; + $transcripts = $what_did_they_say->get_transcripts($post->ID); + if (!empty($transcripts)) { + if (isset($transcripts[$language])) { $transcript = $transcripts[$language]; } + } + return $transcript; +} + +function the_media_transcript($language = null) { + $transcript = apply_filters('the_media_transcript', get_the_media_transcript()); + echo $transcript; +} + +function get_the_language_name($language = null) { + global $what_did_they_say; + + if (is_null($language)) { $language = $what_did_they_say->get_default_language(); } + return $what_did_they_say->get_language_name($language); +} + +function the_language_name($language = null) { + $name = apply_filters('the_language_name', get_the_language_name($language)); + echo $name; +} + ?> \ No newline at end of file