From c33591d747b25b64e37d639c6f49ff7c3917ee21 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 23 Sep 2009 22:38:11 -0400 Subject: [PATCH] big work on text and added automatic transcript embedding --- classes/WhatDidTheySayAdmin.php | 21 ++++++++-- classes/partials/_capabilities.inc | 2 + classes/partials/_default-styles.inc | 48 ++++++++++++++++++++--- classes/partials/_introduction.inc | 56 +++++++++++++++++++++++++++ classes/partials/_shortcodes-info.inc | 4 ++ classes/partials/admin.inc | 3 +- 6 files changed, 124 insertions(+), 10 deletions(-) create mode 100644 classes/partials/_introduction.inc diff --git a/classes/WhatDidTheySayAdmin.php b/classes/WhatDidTheySayAdmin.php index 1191178..4842dfb 100644 --- a/classes/WhatDidTheySayAdmin.php +++ b/classes/WhatDidTheySayAdmin.php @@ -18,6 +18,7 @@ class WhatDidTheySayAdmin { 'change_languages' => 'administrator' ), 'load_default_styles' => true, + 'automatic_embedding' => true, 'excerpt_distance' => 30 ); @@ -65,6 +66,10 @@ class WhatDidTheySayAdmin { add_filter('posts_where', array(&$this, 'posts_where')); add_filter('posts_join', array(&$this, 'posts_join')); + + if ($options['automatic_embedding']) { + add_filter('the_content', array(&$this, 'the_content_automatic_embedding'), 15); + } if (isset($_REQUEST['wdts'])) { if (isset($_REQUEST['wdts']['_nonce'])) { @@ -77,6 +82,16 @@ class WhatDidTheySayAdmin { } } + /** + * Attempt to automatically embed transcripts in posts. + */ + function the_content_automatic_embedding($content) { + ob_start(); + transcripts_display(); + the_media_transcript_queue_editor(); + return $content . ob_get_clean(); + } + /** * Filter for WP_Query#get_posts to add searching for transcripts. */ @@ -198,7 +213,7 @@ class WhatDidTheySayAdmin { * @param string $transcript The transcription text. * @return string The processed transcription text. */ - function the_media_transcript($transcript, $output = "") { + function the_media_transcript($transcript, $content = "") { return array($transcript, '
' . do_shortcode($transcript) . '
'); } @@ -207,14 +222,14 @@ class WhatDidTheySayAdmin { * @param string $language The name of the language. * @return string The processed language name. */ - function the_language_name($language, $output = "") { + function the_language_name($language, $content = "") { return array($language, '

' . $language . '

'); } /** * Handle the_matching_transcript_excerpts. */ - function the_matching_transcript_excerpts($transcripts, $search_string = '', $output = "") { + function the_matching_transcript_excerpts($transcripts, $search_string = '', $content = "") { ob_start(); if (!empty($search_string)) { $language_options = new WDTSLanguageOptions(); diff --git a/classes/partials/_capabilities.inc b/classes/partials/_capabilities.inc index 1738ac5..a19161c 100644 --- a/classes/partials/_capabilities.inc +++ b/classes/partials/_capabilities.inc @@ -4,6 +4,8 @@

+

+ diff --git a/classes/partials/_default-styles.inc b/classes/partials/_default-styles.inc index 2712065..40925c9 100644 --- a/classes/partials/_default-styles.inc +++ b/classes/partials/_default-styles.inc @@ -1,6 +1,6 @@ -

+

@@ -21,8 +21,10 @@ -
-

What Did They Say?!?:', 'what-did-they-say') ?>

+ +

+ +

What Did They Say?!?:', 'what-did-they-say') ?>

.transcript
@@ -38,8 +40,42 @@
-

-

<php the_matching_transcript_excerpts() ?>

-

emphasized, and there will be %d additional characters on each side of the word.', 'what-did-they-say'), $options['excerpt_distance']) ?>

+

+ +

+ + $content containing the filter output.', 'what-did-they-say') ?> +

+ +
+
filter_shortcode_dialog($name, $direction, $speech, $content)
+
$content contains the HTML for dialog blocks.', 'what-did-they-say') ?>
+ +
filter_shortcode_scene_action($description, $content)
+
$content contains the HTML for scene action blocks.', 'what-did-they-say') ?>
+ +
filter_shortcode_scene_heading($description, $content)
+
$content contains the HTML for scene heading blocks.', 'what-did-they-say') ?>
+ +
the_media_transcript($transcript, $content)
+
$content contains the HTML for a single transcript.', 'what-did-they-say') ?>
+ +
the_language_name($language, $content)
+
$content contains the HTML for a language name.', 'what-did-they-say') ?>
+ +
the_matching_transcript_excerpts($transcripts, $search_string, $content)
+
$content contains the HTML for all the provided $transcripts that match $search_string.', 'what-did-they-say') ?>
+
+ +

+ +

+ +
+function my_theme_the_language_name($language, $content) {
+  return array($language, "<div class='language-name'>${content}</div>");
+}
+
+add_filter('the_language_name', 'my_theme_the_language_name', 15);
diff --git a/classes/partials/_introduction.inc b/classes/partials/_introduction.inc new file mode 100644 index 0000000..5a9151b --- /dev/null +++ b/classes/partials/_introduction.inc @@ -0,0 +1,56 @@ + +

+ +

+ What Did They Say?!? gives you great control over adding and managing transcripts for your comics, videos, or audio.', 'what-did-they-say') ?> + +

+ +

+ +

+ What Did They Say?!? can attempt to embed excerpts into your posts automatically:', 'what-did-they-say') ?> +
+ + + + + +

+ +

+ +

+ +
+<?php
+  if (function_exists('transcripts_display') &&
+      function_exists('the_media_transcript_queue_editor')) {
+  transcripts_display(); the_media_transcript_queue_editor();
+} ?>
+ +

+ +

+ What Did They Say?!? will search your transcripts, too.', 'what-did-they-say') ?> + +

+ +
+<php if (function_exists('the_matching_transcript_excerpts')) {
+  the_matching_transcript_excerpts();
+} ?>
+ +

+ ' . __('Styles', 'what-did-they-say') . ''; + printf(__('You can set the number of characters to show in context in search results on the %s page.', 'what-did-they-say'), $link); + ?> +

+ diff --git a/classes/partials/_shortcodes-info.inc b/classes/partials/_shortcodes-info.inc index 316c648..2521960 100644 --- a/classes/partials/_shortcodes-info.inc +++ b/classes/partials/_shortcodes-info.inc @@ -1,6 +1,10 @@

+

+ () +

+

     [scene-heading]Ext. The Old Man's House[/scene-heading]
diff --git a/classes/partials/admin.inc b/classes/partials/admin.inc
index d87c42c..f0fce3a 100644
--- a/classes/partials/admin.inc
+++ b/classes/partials/admin.inc
@@ -1,10 +1,11 @@
  __('Introduction', 'what-did-they-say'),
     'capabilities' => __('Capabilities', 'what-did-they-say'),
     'default-styles' => __('Styles', 'what-did-they-say'),
     'change-languages' => __('Languages', 'what-did-they-say'),
+    'shortcodes-info' => __('Shortcodes Info', 'what-did-they-say'),
     'misc-options' => __('Misc. Options', 'what-did-they-say'),
-    'shortcodes-info' => __('Shortcodes Info', 'what-did-they-say')
   );
 
   extract($this->plugin_data);