big work on text and added automatic transcript embedding

This commit is contained in:
John Bintz 2009-09-23 22:38:11 -04:00
parent c34b93a030
commit c33591d747
6 changed files with 124 additions and 10 deletions

View File

@ -18,6 +18,7 @@ class WhatDidTheySayAdmin {
'change_languages' => 'administrator' 'change_languages' => 'administrator'
), ),
'load_default_styles' => true, 'load_default_styles' => true,
'automatic_embedding' => true,
'excerpt_distance' => 30 'excerpt_distance' => 30
); );
@ -66,6 +67,10 @@ class WhatDidTheySayAdmin {
add_filter('posts_where', array(&$this, 'posts_where')); add_filter('posts_where', array(&$this, 'posts_where'));
add_filter('posts_join', array(&$this, 'posts_join')); 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'])) {
if (isset($_REQUEST['wdts']['_nonce'])) { if (isset($_REQUEST['wdts']['_nonce'])) {
if (wp_verify_nonce($_REQUEST['wdts']['_nonce'], 'what-did-they-say')) { if (wp_verify_nonce($_REQUEST['wdts']['_nonce'], 'what-did-they-say')) {
@ -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. * Filter for WP_Query#get_posts to add searching for transcripts.
*/ */
@ -198,7 +213,7 @@ class WhatDidTheySayAdmin {
* @param string $transcript The transcription text. * @param string $transcript The transcription text.
* @return string The processed transcription text. * @return string The processed transcription text.
*/ */
function the_media_transcript($transcript, $output = "") { function the_media_transcript($transcript, $content = "") {
return array($transcript, '<div class="transcript">' . do_shortcode($transcript) . '</div>'); return array($transcript, '<div class="transcript">' . do_shortcode($transcript) . '</div>');
} }
@ -207,14 +222,14 @@ class WhatDidTheySayAdmin {
* @param string $language The name of the language. * @param string $language The name of the language.
* @return string The processed language name. * @return string The processed language name.
*/ */
function the_language_name($language, $output = "") { function the_language_name($language, $content = "") {
return array($language, '<h3 class="transcript-language">' . $language . '</h3>'); return array($language, '<h3 class="transcript-language">' . $language . '</h3>');
} }
/** /**
* Handle the_matching_transcript_excerpts. * 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(); ob_start();
if (!empty($search_string)) { if (!empty($search_string)) {
$language_options = new WDTSLanguageOptions(); $language_options = new WDTSLanguageOptions();

View File

@ -4,6 +4,8 @@
<input type="hidden" name="wdts[module]" value="capabilities" /> <input type="hidden" name="wdts[module]" value="capabilities" />
<h3><?php _e('Capabilities', 'what-did-they-say') ?></h3> <h3><?php _e('Capabilities', 'what-did-they-say') ?></h3>
<p><?php _e('Determine who can do what with transcripts by setting the minimum role requirements below.', 'what-did-they-say') ?></p>
<table class="widefat fixed"> <table class="widefat fixed">
<tr class="thead"> <tr class="thead">
<th scope="col" class="manage-col"><?php _e('Capability', 'what-did-they-say') ?></th> <th scope="col" class="manage-col"><?php _e('Capability', 'what-did-they-say') ?></th>

View File

@ -21,8 +21,10 @@
</label> </label>
<input class="button" type="submit" value="<?php _e('Change default styles', 'what-did-they-say') ?>" /> <input class="button" type="submit" value="<?php _e('Change default styles', 'what-did-they-say') ?>" />
</form> </form>
<hr />
<p><?php _e('By default, the following styles are used by <strong>What Did They Say?!?</strong>:', 'what-did-they-say') ?></p> <h3><?php _e('Default CSS Selectors Information', 'what-did-they-say') ?></h3>
<p><?php _e('By default, the following CSS selectors are used by <strong>What Did They Say?!?</strong>:', 'what-did-they-say') ?></p>
<dl> <dl>
<dt><code>.transcript</code></dt> <dt><code>.transcript</code></dt>
<dd><?php _e('The container for the transcript', 'what-did-they-say') ?></dd> <dd><?php _e('The container for the transcript', 'what-did-they-say') ?></dd>
@ -38,8 +40,42 @@
<dd><?php _e('Action within a scene', 'what-did-they-say') ?></dd> <dd><?php _e('Action within a scene', 'what-did-they-say') ?></dd>
</dl> </dl>
<p><?php _e('To include transcript excerpts in your search results, add the following template tag to your search results Loop:', 'what-did-they-say') ?></p> <h3><?php _e('Overriding Filters', 'what-did-they-say') ?></h3>
<p><code>&lt;php the_matching_transcript_excerpts() ?&gt;</code></p>
<p><?php printf(__('The first matching word in each transcript will be <strong>emphasized</strong>, and there will be <strong>%d</strong> additional characters on each side of the word.', 'what-did-they-say'), $options['excerpt_distance']) ?></p> <p>
<?php _e('If you want to override how transcript HTML is structured, create hooks in your theme that implement the following filters.', 'what-did-they-say') ?>
<?php _e('All of them return the same parameters that are passed in as an array(), with the return <code>$content</code> containing the filter output.', 'what-did-they-say') ?>
</p>
<dl>
<dt><code>filter_shortcode_dialog($name, $direction, $speech, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for dialog blocks.', 'what-did-they-say') ?></dd>
<dt><code>filter_shortcode_scene_action($description, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for scene action blocks.', 'what-did-they-say') ?></dd>
<dt><code>filter_shortcode_scene_heading($description, $content)</code></dt>
<dd><?php _e('Ouptut <code>$content</code> contains the HTML for scene heading blocks.', 'what-did-they-say') ?></dd>
<dt><code>the_media_transcript($transcript, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for a single transcript.', 'what-did-they-say') ?></dd>
<dt><code>the_language_name($language, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for a language name.', 'what-did-they-say') ?></dd>
<dt><code>the_matching_transcript_excerpts($transcripts, $search_string, $content)</code></dt>
<dd><?php _e('Output <code>$content</code> contains the HTML for all the provided <code>$transcripts</code> that match <code>$search_string</code>.', 'what-did-they-say') ?></dd>
</dl>
<p>
<?php _e('A filter in your theme that would change the display of langauge names would look like the following:', 'what-did-they-say') ?>
</p>
<pre>
function my_theme_the_language_name($language, $content) {
return array($language, "&lt;div class='language-name'&gt;${content}&lt;/div&gt;");
}
add_filter('the_language_name', 'my_theme_the_language_name', 15);</pre>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>

View File

@ -0,0 +1,56 @@
<?php if (current_user_can('submit_transcriptions')) { ?>
<h3><?php _e('Introduction', 'what-did-they-say') ?></h3>
<p>
<?php _e('<strong>What Did They Say?!?</strong> gives you great control over adding and managing transcripts for your comics, videos, or audio.', 'what-did-they-say') ?>
<?php _e('Adding transcripts to your posts gives you better search engine visibility and helps disabled users enjoy your content.', 'what-did-they-say') ?>
</p>
<h3><?php _e('Getting Started', 'what-did-they-say') ?></h3>
<p>
<?php _e('<strong>What Did They Say?!?</strong> can attempt to embed excerpts into your posts automatically:', 'what-did-they-say') ?>
<form method="post">
<input type="hidden" name="wdts[_nonce]" value="<?php echo $nonce ?>" />
<input type="hidden" name="wdts[module]" value="automatic-transcripts" />
<label>
<input type="checkbox"
name="wdts[automatic_embedding]"
value="yes"
<?php echo $options['automatic_embedding'] ? 'checked="checked"' : '' ?> />
<?php _e('Enable automatic transcript embedding', 'what-did-they-say') ?>
</label>
<input type="submit" class="button" value="<?php _e('Submit', 'what-did-they-say') ?>" />
</form>
</p>
<p>
<?php _e('If the above method doesn\'t work or you desire more control, you can add the following Template Tags to the appropriate location in your posts Loop:', 'what-did-they-say') ?>
</p>
<pre>
&lt;?php
if (function_exists('transcripts_display') &&
function_exists('the_media_transcript_queue_editor')) {
transcripts_display(); the_media_transcript_queue_editor();
} ?&gt;</pre>
<h3><?php _e('Search Results', 'what-did-they-say') ?></h3>
<p>
<?php _e('When someone searches your site, <strong>What Did They Say?!?</strong> will search your transcripts, too.', 'what-did-they-say') ?>
<?php _e('If you want transcript excerpts to appear in your search results, add the following Template Tag to your search results Loop:', 'what-did-they-say') ?>
</p>
<pre>
&lt;php if (function_exists('the_matching_transcript_excerpts')) {
the_matching_transcript_excerpts();
} ?&gt;</pre>
<p>
<?php
$link = '<a href="#" onclick="make_active($(\'wdts-tab-default-styles\')); return false;">' . __('Styles', 'what-did-they-say') . '</a>';
printf(__('You can set the number of characters to show in context in search results on the %s page.', 'what-did-they-say'), $link);
?>
</p>
<?php } ?>

View File

@ -1,6 +1,10 @@
<?php if (current_user_can('submit_transcriptions')) { ?> <?php if (current_user_can('submit_transcriptions')) { ?>
<h3><?php _e('Shortcodes Info', 'what-did-they-say') ?></h3> <h3><?php _e('Shortcodes Info', 'what-did-they-say') ?></h3>
<p>
<em>(<?php _e('you can easily use these shortcodes with the appropriate buttons above all transcript editors', 'what-did-they-say') ?>)</em>
</p>
<h4><?php _e('Sample Transcript', 'what-did-they-say') ?></h4> <h4><?php _e('Sample Transcript', 'what-did-they-say') ?></h4>
<pre> <pre>
[scene-heading]Ext. The Old Man's House[/scene-heading] [scene-heading]Ext. The Old Man's House[/scene-heading]

View File

@ -1,10 +1,11 @@
<?php <?php
$pages = array( $pages = array(
'introduction' => __('Introduction', 'what-did-they-say'),
'capabilities' => __('Capabilities', 'what-did-they-say'), 'capabilities' => __('Capabilities', 'what-did-they-say'),
'default-styles' => __('Styles', 'what-did-they-say'), 'default-styles' => __('Styles', 'what-did-they-say'),
'change-languages' => __('Languages', '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'), 'misc-options' => __('Misc. Options', 'what-did-they-say'),
'shortcodes-info' => __('Shortcodes Info', 'what-did-they-say')
); );
extract($this->plugin_data); extract($this->plugin_data);